我有一个 IE8 错误的水平滚动条问题, 与此类似:
DIV with overflow:auto and a 100% wide table
(不幸的是,那里建议的解决方案(zoom=1)在这里不起作用,
或者我不知道如何申请)
不应出现水平滚动条
(它不会出现在 FF 或 Chrome 中
但它出现在 IE8 中)
示例代码,带有 CSS 表:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<body>
<div style="display: table;">
<div style="display: table-cell;">
<div style="overflow-y: scroll; height: 19em;">
<div style="width: 30em; height: 30em; background-color: red;"></div>
</div>
</div>
</div>
</body>
</html>
同样的问题,使用绝对定位:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<body>
<div style="position: absolute;">
<div style="overflow-y: scroll; height: 19em;">
<div style="width: 30em; height: 30em; background-color: red;"></div>
</div>
</div>
</body>
</html>
“overflow-x:hidden”解决方案不好,因为它可能会隐藏一些内容;
padding-right 可能有效,但这太肮脏了(多少像素?其他浏览器中会发生什么?如果用户放大页面怎么办?)
最佳答案
设置显示:inline-block;对于包含红色框的 div
<div style="display: table;">
<div style="display: table-cell;">
<div style="overflow-y: scroll; height: 19em; display:inline-block;">
<div style="width: 30em; height: 30em; background-color: red;"></div>
</div>
</div>
关于css - IE8水平滚动条问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5546454/