【问题标题】:z-index iframe InternetExplorer vs Chrome,Fox,z-index iframe InternetExplorer 与 Chrome、Fox、
【发布时间】:2011-02-17 00:16:15
【问题描述】:

img { z-index:1;} iframe { z-index:99;}

<iframe name="frameid" scrolling="no" frameborder="0" height="100" width="100" marginheight="0")></iframe><img src="img.jpg" width="100" height="100" />

Chrome、Fox、Safari 会很好地显示 img.jpg (z-index99 处的 iframe 是空的,所以让我们在下面显示图像)

IE 7 什么都不显示 (iframe 是空的,所以让我们把它涂成白色什么的) 有什么方法可以教 IE 7,* 如果 iframe 上什么都没有,则什么都不显示 我在 msdn 上查看了使用 IFRAME 元素,但是... 谢谢

【问题讨论】:

    标签: css iframe z-index


    【解决方案1】:

    问题似乎与 Z-Index 有关,当我将其删除并将“allowtransparency="true"” 添加到 iframe 时,它​​按预期工作,请查看此 sn-p:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>simple document</title> <style> img { background:red; display:block; position:absolute; top:2px; left:2px; } iframe { border:2px solid blue; position:absolute; top:0; left:0; background:transparent; display:block; zoom:1} body{background:pink} div {position:relative;} </style> </head> <body> <div> <iframe name="frameid" scrolling="no" frameborder="0" height="100" width="100" allowtransparency="true"></iframe> <img src="img.jpg" width="100" height="100" /> </div> </body> </html>

    奇怪,似乎它破坏了代码的布局,但是将其复制并粘贴到 .html 文件中,您可以看到图像显示为 iframe 下方,另一个选项是设置图像作为

    的背景图像

    祝你好运!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-04-03
      • 2014-07-16
      • 2011-12-28
      • 1970-01-01
      • 2014-08-31
      • 2014-08-20
      • 1970-01-01
      相关资源
      最近更新 更多