4

我之前可能以某种方式问过这个问题=) 但是,有谁知道 iFrame 中是否可以有一个固定元素?我的意思是固定我与整个浏览器窗口的关系?

谢谢!

4

2 回答 2

4

否 - 您不能在 iframe 边界之外显示项目。

于 2011-03-30T13:12:39.003 回答
2

“Facebook 应用 iframe”的解决方案 - 您的应用位于 iFrame 中,当用户向下滚动时,整个页面都在向下滚动,包括 facebook 和 iframe:

通常使用 JavaScript,你会像这样定位你的固定元素:

top = window.height() / 2 - $(id).height() / 2
left = window.width() / 2 - $(id).width() / 2

在 iFrame 中执行以下操作:

top = window.parent.pageYOffset + window.parent.height() / 2 - $(id).height() / 2
left = window.width() / 2 - $(id).width() / 2
于 2011-08-17T06:39:55.787 回答