Short version: Why does overflow:auto
cause a div
to the right of a left floated div
not to wrap its text around the left floated div
? (Bonus: Is this an acceptable way to accomplish a column effect?)
Long version...
I have two div
s that I wish to be next to each other, and displayed as columns. The div
on the left has a specific width and height. And the div
on the left is shorter than the div
on the right. However, I do not want the text in the right div
to wrap under the left div.
Here was my first attempt...
<div>
<div style="border:1px solid grey;
width:100px;
height:100px;
float:left;">
Div on the left.
</div>
<div>
Imagine lots and lots of text here...
</div>
<div style="clear:both"/>
</div>
...I knew the text in the right div
would wrap under the left div
. And it did.
Then I remembered a page I had created that had a column effect. I had copied and pasted it from I know not where. All it did was assign overflow:auto
to the div
on the right. It looks like this...
<div>
<div style="border:1px solid grey;
width:100px;
height:100px;
float:left;">
Div on the left.
</div>
<div style="overflow:auto">
Imagine lots and lots of text here...
</div>
<div style="clear:both"/>
</div>
Voila, the right div
s text no longer wrapped under the first (left) div
! The second (right) div
appeared as a column.
So, I read everything I could find on overflow:auto
and found no mention of why I should see this behaviour. Can anyone explain it to me?
Also, is this an acceptable way to achieve a column effect?