Transparent Iframe Body

China☆狼群 提交于 2020-01-30 15:19:46

问题


I need to have a (crossdomain) iframe with dynamic width and height.

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 ?

Can I attach a css property or a transparent gif for the iframe background to make that effect ?

Thanks.


回答1:


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)

<style type="text/css">
 <!-- BODY {background:none transparent;}-->
 </style>

and then embed the iframe like this

<iframe src="frame.htm" allowtransparency="true">



回答2:


This isn't tested, but iframes (any element) should have a default background of being transparent.

If that's not true, you can set them to being transparent in CSS background: transparent

If that doesn't work, you can use CSS opacity filters:
http://www.w3schools.com/Css/css_image_transparency.asp




回答3:


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:

html {
  background-color: transparent !important;
}

And then in the iframe element:

<iframe src="www.." allowtransparency="true">


来源:https://stackoverflow.com/questions/3064199/transparent-iframe-body

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!