CSS div floats
One problem with putting div
floating inside a container (such as another div
) is that the containing div
does not handle the size very well and it ends up collapsing.
Let’s say you have the following HTML:
and the following CSS:
You’ll end up with with a collapsed container (in green).
float 1
float 2
float 3
If add overflow: auto;
to the container, then it will prevent it from collapsing:
float 1
float 2
float 3