Html iframe 背景图片
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1695610/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
iframe background image
提问by Talha Bin Shakir
I have a iframe on my page. I have inserted a background image on it. but its not showing the Image. Here is my code.
我的页面上有一个 iframe。我在上面插入了背景图片。但它没有显示图像。这是我的代码。
<iframe scrolling="auto" allowtransparency="true" name="main" style="width:100%;height:90%" style="background-image:url(img/bg2.jpg)"> </iframe>
回答by jerjer
Try this:
尝试这个:
<iframe scrolling="auto" allowtransparency="true" name="main" style="width:100%;height:90%;background-image:url(img/bg2.jpg)"> </iframe>
if it doesn't work move the background images to the container of the iframe.
如果它不起作用,请将背景图像移动到 iframe 的容器中。
回答by Dudman
Wrap your iframe with div and put it some class. Ex:
用 div 包裹你的 iframe 并把它放在一些类中。前任:
<div class="wrap">
<iframe style="display:none" width="325" height="276" frameborder="0" scrolling="auto"></iframe>
</div>
in css: .wrap{background:url(somepicture);} .wrap iframe{opacity:0;}
在 css: .wrap{background:url(somepicture);} .wrap iframe{opacity:0;}
回答by priyanka.sarkar
Try this .. it should work(tested in IE/Firefox/Google Crome)
试试这个..它应该可以工作(在 IE/Firefox/Google Crome 中测试)
<div><img src="a.JPG"></div>
<div>
<iframe style="display:none" width="325" height="276" frameborder="0" scrolling="auto"></iframe>
</div>