2009-11-08 135 views
8

我的页面上有一个iframe。我已在其上插入背景图片。但它没有显示图像。这是我的代码。iframe背景图片

<iframe scrolling="auto" allowtransparency="true" name="main" style="width:100%;height:90%" style="background-image:url(img/bg2.jpg)"> </iframe> 
+0

您使用的是样式属性,试戴合并成一个 – jerjer 2009-11-08 07:00:20

回答

14

试试这个:

<iframe scrolling="auto" allowtransparency="true" name="main" style="width:100%;height:90%;background-image:url(img/bg2.jpg)"> </iframe> 

,如果它不工作,移动背景图像iframe的容器。

+0

谢谢它的工作正常,但仍然不能在IE浏览器上工作在Firefox上。 – 2009-11-08 07:07:03

+0

+1“allowtransparency =”true“在IE中为我做了诀窍 – hinekyle 2013-04-17 11:53:02

-4

试试这个..它应该工作(在IE/Firefox的/谷歌克罗默测试)

<div><img src="a.JPG"></div> 

<div> 
<iframe style="display:none" width="325" height="276" frameborder="0" scrolling="auto"></iframe> 
</div> 
-1

包装你的iframe与股利,并把它的一些类。 例如:

<div class="wrap"> 
<iframe style="display:none" width="325" height="276" frameborder="0" scrolling="auto"></iframe> 
</div> 

在CSS: .wrap {背景:网址(somepicture);} .wrap IFRAME {不透明度:0;}