A common problem that I have with web pages is floating divs crawling outside their containers.
#wrapper{ border:1px solid red; } #wrapper div{ float:left; font-size: 3em; } ... <div id="wrapper"> <div>Hello World</div> </div>
Real-time example: http://jsfiddle.net/ugUVa/1/
There are many dirty ways to fix this (insert div with clear: both)
The much clearer solution I've seen sets the style of overflowing divs divs to hidden:
Example: http://jsfiddle.net/ugUVa/2/
This works well in browsers, nice and clean, without extra markup. I am happy, but I have no idea WHY it works!
All the documentation I was looking at indicates an overflow: the hidden one is for hiding the contents, not for resizing the parent for his children ...
Can anyone suggest an explanation for this behavior?
thank
html css
Chris Feb 08 2018-12-12T00: 00Z
source share