I have 4 sets of Divs in my sample. In my 1st two divs, I have 2 divs that I want to be side by side.
I have other divs that I can get side by side fine. Normally, you just put a "float:left" on both divs to get them next to each other and "float:right" on one of them to get them side by side but one will be all the way to right.
It turns out the Clear:Left solves the problem. But not really. One question is why does the Blue border surround the Div2 and the Div3 is outside of the border.
In the 2nd example neither of the Divs (Div5 and Div6) is inside the border and the border is just a straight line above both divs.
Both should be inside the blue border. The blue border extends to the end of the page, which is expected.
In the last to divs, I can line up all the divs fine by setting all of them to be float:left.
But I want the Div15 and Div16 to be below Div13 and Div14 so that I have 2 rows and 2 columns.
I thought by putting a clear in the Div15, that would move Div15 to the next line (which it does), but now Div16 is below Div15 (because both are not Float:left, I think).
Also the blue border is now around the 1st 3 Divs and the 4th div is outside the border.
How do i get the 2 rows and 2 columns and the blue border to surround the whole thing?
Thanks,
Tom
I have other divs that I can get side by side fine. Normally, you just put a "float:left" on both divs to get them next to each other and "float:right" on one of them to get them side by side but one will be all the way to right.
It turns out the Clear:Left solves the problem. But not really. One question is why does the Blue border surround the Div2 and the Div3 is outside of the border.
In the 2nd example neither of the Divs (Div5 and Div6) is inside the border and the border is just a straight line above both divs.
Both should be inside the blue border. The blue border extends to the end of the page, which is expected.
In the last to divs, I can line up all the divs fine by setting all of them to be float:left.
But I want the Div15 and Div16 to be below Div13 and Div14 so that I have 2 rows and 2 columns.
I thought by putting a clear in the Div15, that would move Div15 to the next line (which it does), but now Div16 is below Div15 (because both are not Float:left, I think).
Also the blue border is now around the 1st 3 Divs and the 4th div is outside the border.
How do i get the 2 rows and 2 columns and the blue border to surround the whole thing?
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml"[/URL] xml:lang="en">
<head>
<title></title>
</head>
<body>
<div id="Div1" style="border: 2px solid blue">
<div id="Div2" style="clear: left; width: 25%; border: 2px solid red">
<span>Div2</span>
</div>
<div id="Div3" style="float: left; width: 25%; border: 2px solid yellow">
<span>Div3 </span>
</div>
</div>
<br />
<br />
<br />
<div id="Div4" style="border: 2px solid blue">
<div id="Div5" style="float: left; width: 25%; border: 2px solid red">
<span>Div5</span>
</div>
<div id="Div6" style="float: left; width: 25%; border: 2px solid yellow">
<span>Div6 </span>
</div>
</div>
<br />
<br />
<br />
<div id="Div7" style="border: 2px solid blue">
<div id="Div8" style="float: left; width: 20%; border: 2px solid Green">
<span>Div8</span>
</div>
<div id="Div9" style="float: left; width: 20%; border: 2px solid orange">
<span>Div9 </span>
</div>
<div id="Div10" style="float: left; width: 20%; border: 2px solid red">
<span>Div10</span>
</div>
<div id="Div11" style="float: left; width: 20%; border: 2px solid yellow">
<span>Div11 </span>
</div>
</div>
<br />
<br />
<br />
<div id="Div12" style="border: 2px solid blue">
<div id="Div13" style="float: left; width: 20%; border: 2px solid Green">
<span>Div13</span>
</div>
<div id="Div14" style="float: left; width: 20%; border: 2px solid orange">
<span>Div14 </span>
</div>
<div id="Div15" style="clear: left; width: 20%; border: 2px solid red">
<span>Div15</span>
</div>
<div id="Div16" style="float: left; width: 20%; border: 2px solid yellow">
<span>Div16 </span>
</div>
</div>
</body>
</html>
Thanks,
Tom