如何在Internet Explorer 8中设置<div>框的最小高度?

4
以下的CSS代码使用了min-height属性应用于一个<div>盒子,在Internet Explorer 8中无法正常工作。以下是一个示例。
 .myDiv
{
    min-height:200px;
    height:auto !important;
    height:200px;

}

如何设置 <div> 盒子的最小高度,以使其在Internet Explorer 8浏览器中正常工作?


应该可以工作。 - Davit
min-height 在 IE7 及以上版本中得到支持。 - Tamil Selvan C
1
为什么你要两次指定 height - Yuriy Galanter
为了确保属性始终得到应用,您必须添加!important属性,这就是为什么height出现两次的原因。 - Davit
“height:auto !important”将会“获胜”,因为它具有更高的特异性。 - steveax
显示剩余2条评论
1个回答

3

您的代码应该像 min-height 属性一样正常工作。

您可以尝试将以下属性添加到您的样式中:

<!--[if IE]>
<style type="text/css">
    .myDiv { 
      height:expression(this.scrollHeight < 200 ? "200px" : "auto");
    }
</style>
<![endif]-->

如果仍然不能正常工作,那么你可能存在其他元素的问题或者没有正确嵌套 .myDiv。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接