本文所分享的知识点是【iframe框架在IE浏览器下将白色背景设为透明色】,欢迎您喜欢我爱IT技术网所分享的教程、知识、经验或攻略,下面是详细的讲解。
iframe框架在IE浏览器下将白色背景设为透明色
最近在做项目的过程中需要频繁的使用iframe画页面的层级框架,大部分浏览器是没有背景的,但是iframe在IE中默认是有一个白色的背景色的,当主背景色不是白色的时候,在这一部分会显得很突兀。帮助手册中给出了解决方案,即将iframe中的allowTransparent属性设置为true,即可。在帮助文档中也给出了相应的示例,示例如下:
<BODY STYLE="background-color: red">
<IFRAME ID="Frame1" SRC="transparentBody.htm" allowTransparency="true">
</IFRAME>
<IFRAME ID="Frame2" SRC="transparentBody.htm" allowTransparency="true"
STYLE="background-color: green">
</IFRAME>
<IFRAME ID="Frame3" SRC="transparentBody.htm">
</IFRAME>
<IFRAME ID="Frame4" SRC="transparentBody.htm"
STYLE="background-color: green">
</IFRAME>
</BODY>
理论上,这样做就没问题了,但是呢IE好像反应不大,依旧还是有白色的背景。其实到了这一步,我们还需要在子页面的<body>标签添加<body bgColor="transparent">,示例如下:
http://img.blog.csdn.net/20140610165850968?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQva3VucGVuZ19tdWJhbw==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center
main.html主页面代码:
<html>
<head>
<title></title>
</head>
<body style="background-color:blue;">
<table
style="width:100%;border:0;height:100%;cellpadding:0;cellspacing:0">
<tr height="100%">
<td height="100%" width="30%">
<iframe id="test1" src="http://www.52ij.com/jishu/test1.html" allowTransparency="true" width="100%" height="100%"></iframe></td>
<td height="100%" width="40%">
<iframe id="test2" src="http://www.52ij.com/jishu/test2.html" allowTransparency="true" width="100%" height="100%"></iframe></td>
<td height="100%" width="30%">
<iframe id="test3" src="http://www.52ij.com/jishu/test3.html" width="100%" height="100%"></iframe></td>
</tr>
</table>
</body>
</html>
test1.html页面代码:
<html>
<head>
<title></title>
</head>
<body bgcolor="transparent">
<h1>test1</h1>
</body>
</html>
test2.html页面代码:
<html>
<head>
<title></title>
</head>
<body>
<h1>test2</h1>
</body>
</html>
test3.html页面代码:
<html>
<head>
<title></title>
</head>
<body>
<h1>test3</h1>
</body>
</html>
这个小例子主要是iframe标签的allowTransparency属性应用,在该属性设置为true并且iframe所加载的子页面的<body>标签背景颜色设置为transparent(透明)时,iframe将透明化。
allowTransparency设置或获取对象是否可为透明。
bgColor 设置或获取对象的背景颜色。
关于iframe框架在IE浏览器下将白色背景设为透明色的相关讨论如下:
相关问题:为什么网页中的iframe背景颜色已设为透明但是在某...
答:没有达到想要的效果,框架那块区域依然是白色。 原因:iframe的allowtransparency属性,把allowtransparency="true" 设为True,这样背景色可以随意设置了。 注意:前提是子页面没有设置背景颜色。 即 >>详细
相关问题:浏览器中怎么让iframe框架背景透明或不显示
答: 在transparentBody.htm文件的标签中,我已经加入了style="background-color=transparent" 通过以下四种IFRAME的写法我想大概你对iframe背景透明效果的实现方法应该会有个清晰的了解: >>详细
相关问题:html5用ie8浏览器在iframe框架下跳转页面时图片丢失。
答:丢失表示路径不对呢 看看是不是修改了路径 >>详细
- 评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
-
