在ie6下将png24图片透明

    没想到IETester中IE6和IE6真实版本不一样。。。之前一直没有实现png图片的透明度,现在发现原来是版本不一样惹的祸。总之,我将解决方法以demo的方式显示出来,以供再次利用。

<!DOCTYPE html>
<html>
    <head>
        <title></title>
        <script type="text/javascript" src="iepngfix_tilebg.js"></script>
        <style type="text/css">
            .box {position : relative; width: 100px; height: 100px; margin: auto;}
            .g-prev,.g-next {position: absolute; top: 50%; margin-top: -13px; width: 13px; height: 25px; background: url("images/ys_print_ico1.png") no-repeat; cursor: pointer; behavior: url("iepngfix.htc")}
            .g-next {background-position: 0 -30px; right: 0;}
        </style>
    </head>
    <body>
    <div class="box">
        <div class="g-prev"></div>
        <div class="g-next"></div>
    </div>
    </body>
</html>

    关键点

    只需要给具有png图片的标签(css)添加 behavior:url("iepngfix.htc")(相对路径),并在iepngfix.htc文件中设置:IEPNGFix.blankImg = 'images/blank.gif';(也是相对路径,根据blank.gif图片放置位置来定义,记住一定是blank.gif文件,下载zip时会附带,别弄成自己定义的图片!我就是弄成自己定义的图片,纠结了好久。。。)

如果需要设置背景图片no-repeat和position,引入 <script type="text/javascript" src="iepngfix_tilebg.js"></script>即可实现。

posted @ 2013-12-06 14:07  tattoos  阅读(194)  评论(3编辑  收藏  举报