在ie7+和ff下默认支持png的透明,ie6里面是没有透明效果的。查了几种方案,备忘
1、采用方案
Code
<input name="image" type="image"
style="filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/test.png',sizingMethod='crop'); "/>
既:
<style type="text/css">
<!--
.pngpic { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/pngpic.png',sizingMethod='crop'); }
-->
</style> 2、备选
Code
function fixPng() {
var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])
if ((version >= 5.5 && version < 7.0) && (document.body.filters)) {
for(var i=0; i<document.images.length;></document.images.length;> var img = document.images[i];
var imgName = img.src.toUpperCase();
if (imgName.indexOf(".PNG") > 0) {
var width = img.width;
var height = img.height;
var sizingMethod = (img.className.toLowerCase().indexOf("scale") >= 0)? "scale" : "image";
img.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + img.src.replace('%23', '%2523').replace("'", "%27") + "', sizingMethod='" + sizingMethod + "')";
img.src="images/blank.gif" mce_src="images/blank.gif";
img.width = width;
img.height = height;
}
}
}
}