网站首页  汉语字词  英语词汇  考试资料  写作素材  旧版资料

请输入您要查询的考试资料:

 

标题 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=test1.html allowtransparency=true width=100% height=100%></iframe></td>
    <td height=100% width=40%>
    <iframe id=test2 src=test2.html allowtransparency=true width=100% height=100%></iframe></td>
    <td height=100% width=30%>
    <iframe id=test3 src=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 设置或获取对象的背景颜色。
随便看

 

在线学习网考试资料包含高考、自考、专升本考试、人事考试、公务员考试、大学生村官考试、特岗教师招聘考试、事业单位招聘考试、企业人才招聘、银行招聘、教师招聘、农村信用社招聘、各类资格证书考试等各类考试资料。

 

Copyright © 2002-2024 cuapp.net All Rights Reserved
更新时间:2025/5/13 3:44:12