var imgStyle = “display:inline-block;” + img.style.cssText;
if (img.align == “left”) imgStyle = “float:left;” + imgStyle;
if (img.align == “right”) imgStyle = “float:right;” + imgStyle;
if (img.parentElement.href) imgStyle = “cursor:hand;” + imgStyle;
var strNewHTML = “<span “+ imgID + imgClass + imgTitle + “style=”” + “width:” + img.width + “px; height:” + img.height + “px;” + imgStyle + “;”
+ “filter:progid:DXImageTransform.Microsoft.AlphaImageLoader” + “(src='” + img.src + “‘, sizingMethod=’scale’);”></span>”;
img.outerHTML = strNewHTML;
i = i-1;
}
}
}
window.attachEvent(“onload”, correctPNG);
</script>
<![endif]–>
四.调用iepngfix.htc解决IE6PNG背景灰及拉伸问题
此方法来自:http://www.twinhelix.com/css/iepngfix/ 此方法基于Winodws平台,在Linux下不支持htc,没有验证过,但有网友发文证实。
以下片段添加至css文件
<div class="pngImg">PNG背景图片</div> <img src="png图片" class="pngImg" alt="">
详细的应用方法这里就不介绍啦。
在逼不得已且身不由己必须使用PNG的情况下,这种方法应该是比较优秀的,虽然不能完美的解决IE6的平铺,但是至少是实现了拉伸,使得很多情况下可以代替平铺来使用。当然效率的问题任然是存在
五.让“块”透明的方法
.div { FILTER: alpha(opacity=20); moz-opacity: 0.2; opacity: 0.2;}
测试IE6,IE7,IE8,FF2,FF3均通过。提示:IE6,IE7需设置一个宽度(100%也行),否则看不到效果。
六.DD_belatedPNG,解决IE6不支持PNG绝佳方案
整个互联网上解决这个IE6的透明PNG的方案也是多不胜数,从使用IE特有的滤镜或是e xpression,再到javascript+透明GIF替代.但是这些方法都有一个缺点,就是不支持CSS中backgrond-position与 background-repeat.
而我今天介绍DD_belatedPNG,只需要一个理由,就是它支持backgrond-position与background-repeat.这是其他js插件不具备的.同时DD_belatedPNG还支持a:hover属性,以及<img>.
看Demo: http://www.ediyang.com/demo/DD_Png/
原理
这个js插件使用了微软的VML语言进行绘制,而其他多数解决PNG问题的js插件用的是AlphaImageLoader滤镜.
使用方法
/Files/aKing/解决IE6透明PNG.rar
1.在这里下载DD_belatedPNG.js文件.
http://dillerdesign.com/experiment/DD_belatedPNG/#download
2.在网页中引用,如下:
<!–[if IE 6]>
<script src=”DD_belatedPNG.js” mce_src=”DD_belatedPNG.js”></script>










