zoukankan      html  css  js  c++  java
  • IE6 png 透明

    style="FILTER: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=images/fl.png')"

    语法:
    filter : progid:DXImageTransform.Microsoft.AlphaImageLoader ( enabled=bEnabled , sizingMethod=sSize , src=sURL )

    enabled : 可选项。布尔值(Boolean)。设置或检索滤镜是否激活。true | false true : 默认值。滤镜激活。
    false : 滤镜被禁止。

    sizingMethod : 可选项。字符串(String)。设置或检索滤镜作用的对象的图片在对象容器边界内的显示方式。 crop : 剪切图片以适应对象尺寸。
    image : 默认值。增大或减小对象的尺寸边界以适应图片的尺寸。
    scale : 缩放图片以适应对象的尺寸边界。

    src : 必选项。字符串(String)。使用绝对或相对 url 地址指定背景图像。假如忽略此参数,滤镜将不会作用。

    特性:
    Enabled : 可读写。布尔值(Boolean)。参阅 enabled 属性。
    sizingMethod : 可读写。字符串(String)。参阅 sizingMethod 属性。
    src : 可读写。字符串(String)。参阅 src 属性。

    说明:
    在对象容器边界内,在对象的背景和内容之间显示一张图片。并提供对此图片的剪切和改变尺寸的操作。如果载入的是PNG(Portable Network Graphics)格式,则0%-100%的透明度也被提供。
    PNG(Portable Network Graphics)格式的图片的透明度不妨碍你选择文本。也就是说,你可以选择显示在PNG(Portable Network Graphics)格式的图片完全透明区域后面的内容。

    实例:解决IE6下png透明失效的问题。

    CSS样式:

    .png{
    _background: url(http://www.snowangel.cn/images/angel.png) no-repeat !important;
    filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=noscale, src="http://www.snowangel.cn/images/angel.png");
    background:none;
    118px;height:133px;
    }

    .png div{position:relative;}

    HTML代码:

    <div class="png">
    <div>
    CSS 背景PNG透明 及 链接失效问题解决
    </div>
    </div>

    /*
    兼容IE6.0、IE7.0、FF,
    IE7.0和新版的FF其实是可以不加filter滤镜直接透明的。
    */

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    <script language="JavaScript">
    function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
    {
        var arVersion = navigator.appVersion.split("MSIE")
        var version = parseFloat(arVersion[1])
        if ((version >= 5.5) && (document.body.filters))
        {
           for(var j=0; j<document.images.length; j++)
           {
              var img = document.images[j]
              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
                 j = j-1
              }
           }
        }    
    }
    window.attachEvent("onload", correctPNG);
    </script>
    <style type="text/css">
    <!--
    body {
    background-color: #9999CC;
    }
    -->
    </style></head>

    <body>
    把图片换成你自己的图片
    <img src="img/icon_face_03.png" width="30" height="30" /><!--把图片换成你自己的图片 -->
    <img src="img/icon_face_05.png" width="30" height="30" />
    <img src="img/menu_title_over.png" width="130" height="36" />
    </body>
    </html>     

  • 相关阅读:
    设计模式课程 设计模式精讲 17-2 模板方法模式coding
    设计模式课程 设计模式精讲 17-1 模板方法模式讲解
    设计模式课程 设计模式精讲 16-2,3 代理模式Coding-静态代理-1
    设计模式课程 设计模式精讲 16-1 代理模式讲解
    设计模式课程 设计模式精讲 15-3 桥接模式源码解析
    设计模式课程 设计模式精讲 15-2 桥接模式Coding
    HTML 文档之 Head 最佳实践
    CSS深入理解学习笔记之line-height
    webRTC实战总结
    浅析CSS里的 BFC 和 IFC
  • 原文地址:https://www.cnblogs.com/sarahVSEve/p/2584511.html
Copyright © 2011-2022 走看看