IE6实现最小高度min-height和最大高度max-height
最小高度
height:auto !important;
height:400px;
min-height:400px;
- 由于IE6对!important的解释存在bug,所以它只识别height:400px这一句,超过400px后,IE6自身会增加盒子的高度;
- IE7和其他标准浏览器三句都能识别,虽然定义height:400px,但又有了height:auto !important,所以超过400px也能自动增加盒子的高度。
最大高度
height:auto !important;
height:500px;
max-height:500px;
overflow:hidden;
- IE6不识别max-height:400px和height:auto !important这两句,超过400px(也就是我们所希望的最大高度)后的内容将自动以藏;
- IE7及其他标准浏览器全部识别,所以有期望的效果。但仍然存在一个问题:在没有任何内容的时候,IE6里还是会有400px的高度。因为IE6对!important的解释存在bug4,这时IE6只认height:400px,而不认height:auto !important,所以在IE6里自然就出现500px的高度。最大高度man-height应用相对较少,因为有可能会出现某些我们没有考虑到的因素而使内容超高了这个最大高度man-height,那么就可能会使页面不美观。

浙公网安备 33010602011771号