How to increase CSS container height to accomodate floats
September 23, 2009 03:56:46 Last update: September 23, 2009 03:56:46
This trick came from quirksmode.
With this CSS:
the container DIV height remains 0 no matter how tall the contained floats are. Two tricks were offered:
With this CSS:
div.container { border: 1px solid #000000; } div.left { width: 45%; float: left; } div.right { width: 45%; float: right; }
the container DIV height remains 0 no matter how tall the contained floats are. Two tricks were offered:
- Add a DIV after the two floats with
clear:both - Change the container CSS to:
div.container { border: 1px solid #000000; overflow: auto; /* hidden and scroll also works */ width: 100% }