CSS float property tweak

Author: | Posted in CSS, Web 1 Comment
css

If you have ever done any work styling a web page with CSS, specifically the float attribute, you may have come across a minor annoyance. If you are floating a div within a larger ‘main’ div, you usually want the height of the main div to expand/shrink according to the height of the div placed inside. However, in some browsers, if the inside div inside is floated, the main div does not recognize the height of the div inside. This can be avoided by simply adding the following attribute to your main div in your CSS:

#main { 
overflow:hidden; 
}

The main div will now size itself according to the size of the div inside. Hope this helps!

  • http://jonberes.com Jonathan

    You just saved my life