position:fixed inside of an iframe

2019-04-08 06:28发布

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.

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?

标签: css iframe
3条回答
我想做一个坏孩纸
2楼-- · 2019-04-08 07:07

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).

查看更多
做个烂人
3楼-- · 2019-04-08 07:09

Chrome has a bug that doesn't fix elements with position:fixed if:

a) you use CSS3 transform in any element, and/or

b) you have a child element positioned outside the box of it's parent element

Oddly enough, the bug was reported back in 2009 and it's still open: https://code.google.com/p/chromium/issues/detail?id=20574

查看更多
Animai°情兽
4楼-- · 2019-04-08 07:09

Here is similar question fixed vertical positioning of css within an 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

Can you provide code you are working on?

查看更多
登录 后发表回答