About Floating Divs Inside a Container (Float)

2 floated elements inside a container. The container doesn’t expand to contain the floats. There are a lot of solutions to this, such as sticking in an element to clear the floats (bleh) before closing the container, using the :after pseudo-class to inject something to clear the floats, or setting a fixed height for the container, using a min-height workaround – the list goes on. The simple, all-conquering method of getting around this problem? Float the container too. It will expand to fit the enclosed floats perfectly, whatever height they are.
Source:

http://www.yongfook.com/items/view/81/10-dirty-little-web-development-tricks

This entry was posted in Web Design. Bookmark the permalink.

Leave a Reply