CSS 在 IE 中固定 div 最大高度?

标签 css internet-explorer

我有一个固定的 div 设置:

.box {
position: fixed;
width: 600px;
bottom: 20px;
left: 50%;
max-height: 400;
overflow:auto;
}

我遇到的问题是,在 Internet Explorer 上它会忽略最大高度,即使我设置了 overflow: scroll;,div 也会向上扩展并超出 View ,没有滚动条。

顺便说一句,我正在使用 hack 来做固定的绝对位置框,这样它们就可以在不考虑滚动的情况下留在屏幕上,如果这很重要的话:

* { margin: 0; }
* html .box { position: absolute; }

最佳答案

试试这个:

* html .box{ 
height: expression( this.scrollHeight > 399 ? "400px" : "auto" ); /* fix for ie 5+ */
}
.box {
max-height: 400px; 
position: fixed;
width: 600px;
bottom: 20px;
left: 50%;
overflow:auto;
}

关于CSS 在 IE 中固定 div 最大高度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8753631/

相关文章:

html - 如何将图像调整为 div 的背景?

html - CSS 基本 float 布局,页脚的 margin-top

html - IE 奇怪的 CSS 与 FF 和 chrome 在字体大小上的区别

css - 背景图像/颜色在 IE 中不可见

javascript - Internet Explorer (7-8-9) 似乎会从 JavaScript 中删除字符,这会破坏许多功能

internet-explorer - 具有VBA输入事件的Internet Explorer自动化

html - 如何在它们之间留出空间?

css - 物化框架 : responsive logo in navbar

html - 在 Lotus Notes Xpage 中解析值

javascript - Underscore.js 模板 IE9/IE10 未返回正确的代码