ITeye博客

iframe在IE中的透明问题与allowTransparency属性

lllt · 2011-02-18 16:39 · css · Web前端 · Markdown

使用iframe调用的页面,在IE下(不包括IE9)会以白色背景显示(被调用页面没有设置背景颜色,以及系统的背景颜色默认为白色),如何让其透明?

网络上已经有很多答案:

在iframe标签中加上 allowTransparency="true" 属性

即:
<iframe src="iframe.html" width="600px" height="500px" allowtransparency="true"  scrolling="no" frameborder="0"></iframe>
 有人说,被调用的页面的body中要加上style="background-color:transparent",其实是没有必要的,在IE5.5以上(不包括)版本中,已经没有必要使用。

 allowTransparency属性是针对iframe的特殊属性,仅对ie起到一定的作用,而其属性值,即上文提到的“true”则是<span style="color:red">不必须的</span>,也就是说只要iframe中有allowTransparency属性存在,无论其值为多少,哪怕是“false”,也会对IE中iframe的透明起到作用,这也自然说明,其不用定义值也可以起到作用,那么<span style="color:red">在iframe只用加入“allowTransparency”即可</span>。

 即:
<iframe src="iframe.html" width="600px" height="500px" allowtransparency  scrolling="no" frameborder="0"></iframe>

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。