Opera 浏览器渲染错误:垂直溢出和绝对定位。有人知道解决方法吗?
我正在尝试解决 Opera 中看似错误的问题。
不受欢迎的行为 是 Opera 在浏览器窗口上放置了不必要的垂直滚动条。
当我有一个位置为relative且具有overflow-y:auto的外部div和一个位置为absolute且恰好比浏览器窗口的高度高的嵌套内部div时,就会发生这种情况。
例如:
<style type="text/css">
#outer {
position: relative;
overflow-y: auto;
width: 200px;
height: 200px;
}
#inner {
position: absolute;
height: 2000px;
width: 50%;
border: 2px dashed blue;
background: deeppink;
}
</style>
<div id="outer">
<div id="inner">Inner</div>
</div>
这是一个演示:
http://www.jaysweeney.com.au/overflow_issue.html
有趣的是,从上面的demo可以看到,并没有出现这个问题 用于水平溢出。
以下是我在 Opera 中看到的屏幕截图:
http://www.jaysweeney.com。 au/screen.png
我在 OS X 上使用 Opera 11.01。
如果有人知道此问题的解决方法,请告诉我。此刻我很困惑 更改我的标记和 JavaScript 以不使用绝对定位需要太多工作。
预先感谢,
杰伊。
I'm trying to workaround what looks like a bug in Opera.
The undesired behaviour
is that opera puts an unnecessary vertical scrollbar on the browser window.
This happens when I have an outer div which is position:relative and has overflow-y:auto and an nested inner div which is position:absolute and happens to be taller than the height of the browser window.
for example:
<style type="text/css">
#outer {
position: relative;
overflow-y: auto;
width: 200px;
height: 200px;
}
#inner {
position: absolute;
height: 2000px;
width: 50%;
border: 2px dashed blue;
background: deeppink;
}
</style>
<div id="outer">
<div id="inner">Inner</div>
</div>
Here is a demo:
http://www.jaysweeney.com.au/overflow_issue.html
Interestingly, as you can see from the above demo, this problem does not occur
for horizontal overflow.
Here is a screenshot of what I'm seeing in Opera:
http://www.jaysweeney.com.au/screen.png
I'm using Opera 11.01 on OS X.
If anyone knows a workaround for this issue, please let me know. At the moment I'm stumped
and its too much work to change my markup and javascript to not use absolute positioning.
Thanks in advance,
Jay.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来这确实是一个错误。
我能想到的唯一解决方法是使用 body {overflow-y: hide;} 完全关闭浏览器窗口上的垂直滚动条
但是,这种措施可能有点过于激进......
It seems indeed like this is a bug of sorts.
Only workaround I can think of is to turn off the vertical scrollbar on the browser window completely by using body {overflow-y: hidden;}
However, it's possible that's a bit too radical a measure...