Published in: CSS
URL: http://www.cssplay.co.uk/boxes/minheight.html
Since min-height doesn't work in IE, this code makes up for IE's shortcomings. The first part of the code is the correct code that works in Firefox and Safari. The second part of the code is for IE. Internet Explorer will ignore min-height and is just given a height of 8em. The IE bug automatically expands the container to fit the extra text.
/* for browsers that don't suck */ .container { min-height:8em; height:auto !important; } /* for Internet Explorer */ /*\*/ * html .container { height: 8em; } /**/
Comments
Subscribe to comments
You need to login to post a comment.

I wanted to make it clear that the the 8em is arbitrary and can be whatever height you would like it to be.
You don't really need the "* html" part of the IE definition, I think. This same solution can be found on DustinDiaz's site (http://www.dustindiaz.com/min-height-fast-hack/) without it. Example:
selector { min-height:500px; height:auto !important; height:500px; }
If you don't mind the undercore hack you can do it even shorter:
selector { min-height: 500px; _height: 500px; }
This way you avoid using !important for compliant browsers which may or may not trip you up later down the line (through css or style set through js).