【问题标题】:Cant create iframe with fixed position无法创建具有固定位置的 iframe
【发布时间】:2014-04-17 23:11:16
【问题描述】:

我需要创建具有固定(绝对)位置的 iframe。 我用过

<iframe src="http://www.whatismyreferer.com" width="300" height="300" style="position: fixed; left: 100; top: 10"></iframe>

但它不起作用:( 我的 iframe 显示样式“左”和“上”为 0

那么问题是如何在页面上创建具有固定位置的 iframe 并正确设置 left 和 top 参数?

问候!

【问题讨论】:

标签: html css


【解决方案1】:

修改为100px10px,定位生效。

在使用 CSS 或内联 CSS 时,您需要指定像素 (px),否则会出现问题。

【讨论】:

  • 谢谢!适用于除 IE7 之外的所有现代浏览器。我会寻找解决的方法。
  • 没问题,如果您不介意将我的答案投票为正确,我将不胜感激!
【解决方案2】:

尝试在您的 iframe 周围放置一个 div,并将您的样式设置应用到该 div 而不是 iframe:

<div style="position: fixed; left: 100; top: 10">    
<iframe src="http://www.whatismyreferer.com" width="300" height="300" ></iframe>
</div>

由于新的 div 包含 iframe,您应该能够以这种方式控制它

【讨论】:

    猜你喜欢
    • 2011-05-10
    • 1970-01-01
    • 2012-01-08
    • 2020-04-26
    • 1970-01-01
    • 1970-01-01
    • 2012-03-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多