此外iframe在IE中长宽为300*150,其中边框为2px宽;FF中为304*154,边框也同样为2px。(这里所说宽算边框的宽度)
现有两个文件:main.html 和 t ransparentBody.html
其中transparentBody.htm是嵌套在main.htm之中,为了便于看效果在BODY中加入蓝色背景请看效果图:
main.html 代码如下: <!DOCTYPE html PUBLIC "-//W3C//DTDXHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><head> <metahttp-equiv="Content-Type" content="text/html; charset=utf-8"/><title>main</title></head> <body><iframe name="main"src="transparentBody.htm"></iframe></body></html>

ransparentBody.html代码 <!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><head> <metahttp-equiv="Content-Type" content="text/html; charset=utf-8"/><title>transparentBody</title></head><body> ...</body></html>
首先,在transparentBody.htm的<body>中设定,即为透明样式
然后,在<iframe name="main"src="transparentBody.htm"></iframe>之中加入frameborder="0"和allowTransparency="true"
<iframe name="main" src="transparentBody.htm"frameborder="0"allowTransparency="true"></iframe>到此,iframe背景透明效果搞定。
代码中
allowTransparency指是否允许透明,
frameborder="0"是指边框为不可见。
大家可以把上面的代码复制下来测试下。怎么样,ie中iframe背景也透明了,很开心吧。希望能对php爱好者和爱好php学习的朋友一些帮助。