Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When child divs are floated, parent divs lose auto-height

Tags:

I have a parent div called main. It has a bunch of child divs in it, which I floated left or right.

When I finished floating the last one, the height of the main div completely vanished, throwing off the layout of my page. I gave it a height:100%; just for now, but it will be overly tall on most resolutions. How can I keep it at a fluid height, only as much as needed to contain the elements?

like image 545
AKor Avatar asked Feb 15 '11 22:02

AKor


1 Answers

Contain your floats.

On the div called main add overflow:hidden;. That should contain it.

like image 153
cp3 Avatar answered Oct 27 '22 01:10

cp3