CSS 位置:固定在 iframe 内
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8304148/
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
position:fixed inside of an iframe
提问by crickeys
For some reason, if I load an html page that has position:fixed on something, but I load it in an iframe, the fixed positions to not seem to render as fixed, but look more like absolute positioning.
出于某种原因,如果我加载了一个带有 position:fixed 的 html 页面,但我将它加载到 iframe 中,则固定位置似乎不会呈现为固定位置,但看起来更像是绝对定位。
I'm not expecting the fixed divs to be fixed relative to the parent document. I would just think that they would be fixed in the iframe. Is this not possible in an iframe?
我不希望固定的 div 相对于父文档是固定的。我只是认为它们会被固定在 iframe 中。这在 iframe 中是不可能的吗?
回答by Nighto
Chrome has a bug that doesn't fix elements with position:fixed
if:
Chrome 有一个错误,它不能通过以下方式修复元素position:fixed
:
a) you use CSS3 transform in anyelement, and/or
a) 您在任何元素中使用 CSS3 变换,和/或
b) you have a child element positioned outside the box of it's parent element
b) 您有一个子元素位于其父元素的框外
Oddly enough, the bug was reported back in 2009 and it's still open: https://code.google.com/p/chromium/issues/detail?id=20574
奇怪的是,这个错误是在 2009 年报告的,它仍然是开放的:https: //code.google.com/p/chromium/issues/detail?id=20574
回答by ScottS
They seem to be fixed to the iframe
based off this fiddle: http://jsfiddle.net/ww9mK/6/(note: jsfiddle uses an iframe
and my height's and width's were just to test scrolling).
它们似乎固定在iframe
基于此小提琴的基础上:http: //jsfiddle.net/ww9mK/6/(注意:jsfiddle 使用 aniframe
而我的高度和宽度只是为了测试滚动)。
回答by Wojciech Bednarski
Here is similar question fixed vertical positioning of css within an iframe
这是一个类似的问题,固定的 css 在 iframe 中的垂直定位
It looks like there is no problem with position fixed to be fixed to the iframe. Example: http://digitaldreamer.net/media/examples/iframe-site.html
固定到 iframe 的位置固定看起来没有问题。示例:http: //digitaldreamer.net/media/examples/iframe-site.html
Can you provide code you are working on?
你能提供你正在处理的代码吗?