代码改变世界

IE CSS Min-Height Hack

2011-09-04 17:16  msover  阅读(222)  评论(0)    收藏  举报

IE CSS Min-Height Hack

#box {
    min-height:100px;
}

Solution/Hack One

Since, IE doesn’t understand min-height, we have to force a regular height on the element that the other browsers can’t see:

#box {
    min-height:100px;
}
/* mac hide \*/
* html #box{height:500px}
/* end hide */

To me personally, this feels right (because we’re doing something specifically for IE and hiding it from other browsers), except for one thing: it involves two hacks. As the comments suggest, IE 5 (I think) for MAC does implement the height property correctly. This just gets worse and worse, doesn’t it?

Solution/Hack Two

#box {
    min-height:100px;
    height: 100px;
}
 
html > body #box {
    height: auto;
}

#div {
min-height: 100px;
_height: 100px;
}