css - IE8水平滚动条问题

标签 css internet-explorer-8

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

相关文章:

css - 试图在 IE8-11 和 Chrome/Firefox 中绝对居中一个 div

css - 菜单下的子菜单不显示

javascript - 一个简单的语法奇迹 : access html object by their global name under IE?

javascript - 条件语句和内联样式 - JQuery

html - li 元素的导航和文本

css - 显示 : Table-cell not setting height constantly xbrowser (ie8 table bug)

javascript - IE7、IE8、IE9 对 Laravel 应用程序的支持,Bootstrap 为 "placeholder"

internet-explorer-8 - 检测IE8兼容模式

javascript - 使用普通 JS 显示/隐藏 div

css - 响应式电子邮件在 iPhone 上不起作用