CSS 透明的 iframe 正文
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3064199/
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
Transparent Iframe Body
提问by user345311
I need to have a (crossdomain) iframe with dynamic width and height.
我需要一个具有动态宽度和高度的(跨域)iframe。
My question is, Can I create an iframe with 100% size and a transparent background that will show the parent of this iframe, behind it ?
我的问题是,我可以创建一个具有 100% 大小和透明背景的 iframe 来显示该 iframe 的父级,在它后面吗?
Can I attach a css property or a transparent gif for the iframe background to make that effect ?
我可以为 iframe 背景附加一个 css 属性或一个透明的 gif 来实现这种效果吗?
Thanks.
谢谢。
回答by Hymanson5
yes you can (if i understand your question correctly)
是的,你可以(如果我正确理解你的问题)
heres the code if you have edit access to the iframe content put this in the head (of the iframe)
如果您对 iframe 内容具有编辑权限,则代码如下,请将其放在(iframe 的)头部
<style type="text/css">
<!-- BODY {background:none transparent;}-->
</style>
and then embed the iframe like this
然后像这样嵌入 iframe
<iframe src="frame.htm" allowtransparency="true">
回答by Patrik Rikama-Hinnenberg
By inspecting the iframe page you might find out there is color on some parts of the page. My suggestion would be to start from the highest component when adding the transparency:
通过检查 iframe 页面,您可能会发现页面的某些部分有颜色。我的建议是在添加透明度时从最高组件开始:
html {
background-color: transparent !important;
}
And then in the iframe element:
然后在 iframe 元素中:
<iframe src="www.." allowtransparency="true">
回答by Kerry Jones
This isn't tested, but iframes (any element) should have a default background of being transparent.
这未经过测试,但 iframe(任何元素)应具有透明的默认背景。
If that's not true, you can set them to being transparent in CSS background: transparent
如果不是这样,您可以在 CSS 中将它们设置为透明 background: transparent
If that doesn't work, you can use CSS opacity filters:
http://www.w3schools.com/Css/css_image_transparency.asp
如果这不起作用,您可以使用 CSS 不透明度过滤器:http:
//www.w3schools.com/Css/css_image_transparency.asp