Click to See Complete Forum and Search --> : DIVS not floating


romsok
11-25-2009, 07:48 PM
Hi,

I have two divs one after the other:


<div id="myDiv" style="float: left; width: 500px;">

</div>

<div id="myDiv2" style="width: 500px;">

</div>


my goal here was to have the first one on the top left of the page, and the second one immediately to the right of it, but the second one is still below the first one.

Could you please point out what I am doing wrong?

Thanks.

CFHutton
11-25-2009, 07:58 PM
float the first one to left, and give the second one a margin that equals the width of the first.

edit: maybe a hair bigger than the first one. Just depends on what you want to do.

A left margin that equals the width of the first div.

Sigh, nite nite time.

dgonz
11-26-2009, 12:41 AM
you need to float both if you want them side by side...

<div id="myDiv" style="float: left; width: 500px;">

</div>

<div id="myDiv2" style="float: left; width: 500px;">

</div>


you can put a <div style="clear:both; height:0; overflow:hidden;"></div> after it if you need those cleared, or clear it if needed on the div after that

CFHutton
11-27-2009, 12:25 AM
You're right, and thanks for the quick reply.

I posted twice beyond the time last night. The last one was me remembering the way to get three columns with css.

Again, thanks for covering for my mistake.