PDA

View Full Version : Need help with styling div with css



mattshiao
Jul 28th, 2010, 04:33 AM
Hi,

I am quite new with styling div tags with css, I know margins and paddings but have troubles with float. Say I have 2 divs within one div, how do I make one div float to the left with 5px margin on left and top, the other float to the right with 5px margin on right and top. The html looks like this:

<div id="divs">
<div id="div1"></div>
<div id="div2"></div>
</div>

The dimension of all divs will change based on the content server page put in.

abduraooft
Jul 28th, 2010, 08:26 AM
*{
margin:0;
padding:0;
}
#divs{
padding-top:5px;
border:1px solid black;
}
#div1{
float:left;
width:49%;
border:1px solid red;
}
#div2{
margin-left:50%;
border:1px solid red;
}

<div id="divs">
<div id="div1"></div>
<div id="div2"></div>
</div>