Html IE7 CSS 滚动 Div 错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/67665/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 22:16:05  来源:igfitidea点击:

IE7 CSS Scrolling Div Bug

htmlcssinternet-explorer-7

提问by frank hadder

I recently came across an IE7 only bug that I thought I'd share so when I come to this site 6 months from now to figure out the same thing, I'll have it on hand.

我最近遇到了一个 IE7 唯一的错误,我想我会分享它,所以当我从现在起 6 个月后来到这个网站找出同样的事情时,我会手头有它。

I believe the easiest way to recreate this bug would be the following html in a page with a declared doctype (it works correctly in "quirks mode" / no-doctype):

我相信重新创建此错误的最简单方法是在具有声明的文档类型的页面中使用以下 html(它在“怪癖模式”/无文档类型下正常工作):

<div style="overflow: auto; height: 150px;">
    <div style="position: relative;">[...]</div>
</div>

In IE7, the outer div is a fixed size and the inner div is relatively positioned and contains more content (assuming the inner div causes an overflow). In all other browsers, this seems to work as expected.

在IE7中,外层div为固定大小,内层div相对定位,包含的内容更多(假设内层div导致溢出)。在所有其他浏览器中,这似乎按预期工作。

Screenshot: bug screenshot

截屏: bug screenshot

回答by frank hadder

The easiest fix would be to add position: relative;to the outer div. This will make IE7 work as intended.

最简单的解决方法是添加position: relative;到外部 div。这将使 IE7 按预期工作。

(See: http://rowanw.com/bugs/overflow_relative.htm).

(参见:http: //rowanw.com/bugs/overflow_relative.htm)。

EDIT:Cache version of the broken link on waybackmachine.org

编辑:waybackmachine.org 上断开链接的缓存版本