You can set outerdiv CSS for this
#outerdiv { overflow: hidden; }
You can also do this by adding an element at the end with clear: both . This can usually be added using JS (not a good solution) or with the pseudo-element :after CSS (not widely supported in older IEs).
The problem is that the containers will not naturally expand to include floating children. Be careful using the first example, if you have any children outside the parent, they will be hidden. You can also use “auto” as the property value, but this will cause scroll bars if any item appears outside.
You can also try floating the parent container, but depending on your design, this may not be possible / difficult.
alex Apr 30 '09 at 0:44 2009-04-30 00:44
source share