首页 > 其他 > 详细

解决ie6下png背景不能透明bug

时间:2014-03-03 21:11:24      阅读:531      评论:0      收藏:0      [点我收藏+]
bubuko.com,布布扣

/*第一种方法:通过滤镜 使用css解决的办法。 注意滤镜下的1像素透明gif的覆盖图片的路径是相对页面写的*/

.banner img{
azimuth: expression(
this.pngSet?this.pngSet=true:(this.nodeName == "IMG" && this.src.toLowerCase().indexOf(‘.png‘)>-1?(this.runtimeStyle.backgroundImage = "none",
this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=‘" + this.src + "‘, sizingMethod=‘image‘)",
this.src = "img/blank.gif"):(this.origBg = this.origBg? this.origBg :this.currentStyle.backgroundImage.toString().replace(‘url("‘,‘‘).replace(‘")‘,‘‘),
this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=‘" + this.origBg + "‘, sizingMethod=‘crop‘)",
this.runtimeStyle.backgroundImage = "none")),this.pngSet=true);
}

bubuko.com,布布扣
bubuko.com,布布扣

//第二种方法:通过js脚本方法

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; i++) {
      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 = "img/blank.gif";
        img.width = width;
        img.height = height;
        }
      }
    }
  }

fixPng();
bubuko.com,布布扣

解决ie6下png背景不能透明bug,布布扣,bubuko.com

解决ie6下png背景不能透明bug

原文:http://www.cnblogs.com/liujinyu/p/3578004.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!