internet-explorer-8 - IE8 溢出 :auto with max-height

标签 internet-explorer-8 overflow css

我有一个可能包含大量数据的元素,但我不希望它破坏页面布局,所以我设置了 max-height: 100pxoverflow: auto,希望在内容不适合时出现滚动条。

在 Firefox 和 IE7 中一切正常,但 IE8 的行为就像存在 overflow:hidden 而不是 overflow:auto

我试过 overflow:scroll,仍然没有帮助,IE8 只是截断内容而不显示滚动条。将 max-height 声明更改为 height 可以使溢出工作正常,它是 max-heightoverflow:auto 的组合> 这会破坏事物。

这也被记录为 official bug in the final, release version of IE8

有解决办法吗?现在我使用 height 而不是 max-height,但它会留下大量空白空间以防数据不多。

最佳答案

这是一个非常讨厌的错误,因为它严重影响了我们在 Stack Overflow 上的 <pre>代码块,其中有 max-height:600width:auto .

它在 IE8 的最终版本中被记录为一个错误,没有修复。

http://connect.microsoft.com/IE/feedback/ViewFeedback.aspx?FeedbackID=408759

有一个非常非常 hacky 的 CSS 解决方法:

http://my.opera.com/dbloom/blog/2009/03/11/css-hack-for-ie8-standards-mode

/*
SUPER nasty IE8 hack to deal with this bug
*/
pre 
{
    max-height: none\9 
}

当然还有其他人提到的条件 CSS,但我不喜欢这样,因为这意味着您在每个页面请求中都提供额外的 HTML 垃圾。

关于internet-explorer-8 - IE8 溢出 :auto with max-height,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7707/

相关文章:

javascript - 在javascript中从数组中删除对象元素

css - 带有空格的内联 block 元素之间的间隙 : nowrap and overflow: scroll parent element

html - 当父级为 100% 时从子元素重置宽度?

php - 为包含的内容网站进行 Bootstrap 导航栏调整

html - IE8 中的页脚问题

css - 为 IE8 修复背景大小 100%?

css - 如何将 anchor 标记 <a> 添加到 html block ?

matlab - 定点开发

html - 滚动不适用于 Firefox 中的 CSS3 flexbox

css - 将 LTR 转换为 RTL div 类?