CSS实现PNG图片背景透明效果

本文介绍了一种在Internet Explorer 6浏览器中实现PNG图片透明效果的方法。通过使用AlphaImageLoader滤镜,可以解决IE6不支持PNG透明的问题,并提供了一个实际的代码示例。需要注意的是,应用此滤镜后可能导致链接失效,可通过设置position属性来解决。

使用PNG图片作背景,但ie6不能显示PNG透明效果,所以要用AlphaImageLoader滤镜来实现. 在CSS文件中要注意图片相对路径:滤镜中的图片路径是相对页面文件,而其它的则是相对CSS文件(注意加粗字). 用这滤镜后IE下链接会失效,用 position: relative;解决这个问题.

以下是代码例子:

Default.aspx代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server">     <title>无标题页</title>     <link href="css/StyleSheet.css" rel="stylesheet" type="text/css" /> </head> <body>     <form id="form1" runat="server">         <div id="wrap"></div>     </form> </body> </html>

 

css/StyleSheet.css: 

#wrap {     margin: auto;     padding: 8px;     text-align: center;     width: 880px;     height: 606px; } /*not for ie 6.0*/ html > body #wrap {     background: url(../css/img/background.png) no-repeat left top; } /*for ie 6.0*/ * html #wrap {     filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale, src= "css/img/background.png" );     background: none; } #wrap a {     color: #c00;     text-decoration: none;     position: relative; }/*解决IE下链接失效的问题*/ #wrap a:hover {     text-decoration: underline; } 

 

 

 

 

 

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值