zoukankan      html  css  js  c++  java
  • IE6下PNG图片对象以及其作为背景透明的处理

    图片对象
    function correctPNG() 

    var arVersion = navigator.appVersion.split("MSIE");
     
    var version = parseFloat(arVersion[1]);
     
    if ((version >= 5.5&& (version < 7&& (document.body.filters)){
    for(var i=0; i<document.images.length; i++

    var img = document.images[i] 
    var imgName = img.src.toUpperCase() 
    if (imgName.substring(imgName.length-3, imgName.length) == "PNG"

    var imgID = (img.id) ? "id='" + img.id + "" : "" 
    var imgClass = (img.className) ? "class='" + img.className + "" : "" 
    var imgTitle = (img.title) ? "title='" + img.title + "" : "title='" + img.alt + "" 
    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=\"" + "" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";" 
    "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader" 
    "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
    img.outerHTML 
    = strNewHTML 
    = i-1 
    }
     
    }
     
    }
     
    }

    然后直接onLoad该方法就可以了

    如果要将PNG做为背景,并且使得其透明,则可以使用如下样式:
    background: url(图片地址) center repeat-y !important;
    background:none;
    filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='图片地址',sizingMethod='scale');
  • 相关阅读:
    cf581B Luxurious Houses
    cf581A Vasya the Hipster
    2015.9.11模拟赛 codevs4162 bzoj1774【无双大王】
    2015.9.11模拟赛 codevs 4160【会玩的】
    2015.9.11模拟赛 codevs 4159【hzwer的迷の数列】
    bzoj2019 [Usaco2009 Nov]找工作
    贪吃蛇!!!
    bzoj3850 ZCC Loves Codefires
    cf509E Pretty Song
    cf509C Sums of Digits
  • 原文地址:https://www.cnblogs.com/pyonline/p/1145595.html
Copyright © 2011-2022 走看看