IE8 overflow:auto with max-height [英] IE8 overflow:auto with max-height

查看:406
本文介绍了IE8 overflow:auto with max-height的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个元素可能包含非常大量的数据,但我不想破坏页面布局,所以我设置 max-height:100px overflow:auto ,希望在内容不合适时显示滚动条。

I have an element which may contain very big amounts of data, but I don't want it to ruin the page layout, so I set max-height: 100px and overflow:auto, hoping for scrollbars to appear when the content does not fit.

在Firefox和IE7中都可以正常工作,但IE8的行为与 overflow:hidden code> overflow:auto 。

It all works fine in Firefox and IE7, but IE8 behaves as if overflow:hidden was present instead of overflow:auto.

我试过 overflow:scroll ,仍然没有帮助,IE8简单地截断内容而不显示滚动条。将 max-height 声明更改为 height 使溢出工作正常,它是 max-

I tried overflow:scroll, still does not help, IE8 simply truncates the content without showing scrollbars. Changing max-height declaration to height makes overflow work OK, it's the combination of max-height and overflow:auto that breaks things.

有解决方法吗?现在我诉诸于使用 height 而不是 max-height ,但它留下了大量的空白空间,很多数据。

Is there a workaround? For now I resorted to using height instead of max-height, but it leaves plenty of empty space in case there isn't much data.

推荐答案

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

This is a really nasty bug as it affects us heavily on Stack Overflow with <pre> code blocks, which have max-height:600 and width:auto.

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

It is logged as a bug in the final version of IE8 with no fix.

a href =http://connect.microsoft.com/IE/feedback/ViewFeedback.aspx?FeedbackID=408759 =nofollow noreferrer> http://connect.microsoft.com/IE/feedback/ViewFeedback.aspx ?FeedbackID = 408759

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

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

There is a really, really hacky CSS workaround:

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批处理。

and of course conditional CSS as others have mentioned, but I dislike that because it means you're serving up extra HTML cruft in every page request.

这篇关于IE8 overflow:auto with max-height的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆