gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 10:06:10 28 4
gpt4 key购买 nike

我有一个固定的 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/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com