0

I am new to CSS designing.

I have developed a page using HTML.

I have a header including buttons like HomePage, MyData, Help. When i click the MyData link, one submenu will come up below it. Like Personal Data ,Official Data and Employee Document.

When I click on Personal Data, on the left hand side of the page a menu will come up with the content Address, Passport Details, PAN etc.

When I click the Address link it will display a table having all the address related data in the center of the page.

Here I have taken a line in between the left menu and center table.

My page

I have used 6 div's and 6 different css's for doing this.

<div id="Fourth_Page_Left_Line"> </div>
<div id="Fourth_Page_Left_Line1"> </div>
<div id="Fourth_Page_Left_Line2"> </div>
<div id="Fourth_Page_Left_Line3"> </div>
<div id="Fourth_Page_Left_Line4"> </div>
<div id="Fourth_Page_Left_Line5"> </div>

CSS:

#Fourth_Page_Left_Line {
    left: 190px;
    top: 130px;
    position: absolute;
    font-size: 20px;
}

#Fourth_Page_Left_Line1 {
    left: 190px;
    top: 133px;
    position: absolute;
    font-size: 20px;
}

#Fourth_Page_Left_Line2 {
    left: 190px;
    top: 136px;
    position: absolute;
    font-size: 20px;
}

#Fourth_Page_Left_Line3 {
    left: 190px;
    top: 139px;
    position: absolute;
    font-size: 20px;
}

#Fourth_Page_Left_Line4 {
    left: 190px;
    top: 142px;
    position: absolute;
    font-size: 20px;
}

#Fourth_Page_Left_Line5 {
    left: 190px;
    top: 145px;
    position: absolute;
    font-size: 20px;
}

Like the same I have to make a line till the bottom of the page, then I have to take another 20 to 25 div's and again I have to create CSS for those div's.

Can anyone tell me how I can reduce the code, instead of using so many div's and CSS, can I use a single div and single CSS to produce the same output?

3 Answers 3

1

CSS

.mainClass {left:190px; top:130px;position:absolute;font-size:20px;}
.mcTop1 {top:150px}
.mcTop2 {top:160px}
.mcTop3 {top:170px}

HTML

<div class="mainClass"></div>
<div class="mainClass mcTop1"></div>
<div class="mainClass mcTop2"></div>
<div class="mainClass mcTop3"></div>
Sign up to request clarification or add additional context in comments.

Comments

0

HTML

<div class="mySmallPanel" id="#Fourth_Page_Left_Line1"></div>
<div class="mySmallPanel" id="#Fourth_Page_Left_Line2"></div>
<div class="mySmallPanel" id="#Fourth_Page_Left_Line3"></div>
<div class="mySmallPanel" id="#Fourth_Page_Left_Line4"></div>

CSS

.mySmallPanel
{
    left:190px;
    top:130px; /* Your top div */
    position:absolute;
    font-size:20px;
}

Just assign a class for each div, then in css file you can set your design

1 Comment

Every of the ID's is using a different value for the top-attribute in the OP.
0

HTML :

<div class="mainclass" id="#Fourth_Page_Left_Line1"></div>
<div class="mainclass" id="#Fourth_Page_Left_Line2"></div>
<div class="mainclass" id="#Fourth_Page_Left_Line3"></div>
<div class="mainclass" id="#Fourth_Page_Left_Line4"></div> 

CSS :

.mainclass{
     left: 190px;
     position: absolute;
     font-size: 20px;
}
#Fourth_Page_Left_Line {
    top: 130px;

}

#Fourth_Page_Left_Line1 {
    top: 133px;

}

#Fourth_Page_Left_Line2 {
    top: 136px;

}

#Fourth_Page_Left_Line3 {
    top: 139px;

}

#Fourth_Page_Left_Line4 {
    top: 142px;

}

#Fourth_Page_Left_Line5 {
    top: 145px;

}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.