position fixed div in iframe not working

2019-04-22 19:48发布

I am working on facebook iframe application . I have one pop up message box inside this application. That pop up is having fixed possition . But its not working as added inside iframe having no scroll.

Is it possible to make pop up fixed in position if its in the iframe having no scroll?

标签: html css iframe
1条回答
地球回转人心会变
2楼-- · 2019-04-22 20:02

Is it possible to make pop up fixed in position if its in the iframe having no scroll?

Nope - the iframe is a document in itself. Anything with position: fixed in there is not fixed relative to the main document.

If you want something to be fixed relative to the main document, you need to put it into the main document - either directly, or by copying the node using JavaScript (using jQuery is a good idea in such a case.)

For the latter to work, both the main document and the iframed document need to be on the same protocol, port, and domain.

查看更多
登录 后发表回答