CSS最大高度属性 [英] CSS Max Height Property

查看:95
本文介绍了CSS最大高度属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个很好的跨浏览器方式来设置DIV的max-height属性,当该DIV超出max-height时,它会变成滚动条溢出?


<很遗憾,IE6不需要为IE6使用表达式,然后为所有其他浏览器设置max-height:


  div {
_height:expression(this.scrollHeight> 332?333px:auto); / * sets max-height for IE6 * /
max-height:333px; / *为所有符合标准的浏览器设置max-height值* /
overflow:scroll;
}

溢出:auto在大多数情况下最有可能工作, 。


Is there a good cross-browser way to set a max-height property of a DIV and when that DIV goes beyond the max-height, it turns into an overflow with scroll bars?

解决方案

Sadly IE6 doesn't so you have to use an expression for IE6, then set the max-height for all other browsers:

 div{
       _height: expression( this.scrollHeight > 332 ? "333px" : "auto" ); /* sets max-height for IE6 */
       max-height: 333px; /* sets max-height value for all standards-compliant browsers */
       overflow:scroll;
}

Overflow:auto would most likely work in most cases for have any extra spill over.

这篇关于CSS最大高度属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆