PNG transparency

Discussion in 'HTML & Website Design' started by finsofts, Aug 3, 2009.

  1. #1
    How to implement PNG transparency in web designs using CSS...

    can you explain how to do it, is that makes site takes increased load time?
     
    finsofts, Aug 3, 2009 IP
  2. jamieellis

    jamieellis Active Member

    Messages:
    427
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #2
    Make sure the background-color property of the container element is set to transparent. After that the display will vary from browser to browser. Also remember that many older browsers don't support PNG's. The transparency of the PNG is done in the image itself.
     
    jamieellis, Aug 3, 2009 IP
  3. ricky92

    ricky92 Active Member

    Messages:
    16
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    58
    #3
    If you're talking about IE6's problem with PNGs not being transparent, then yeah, you have to use some javascript file which will increase loading time (just a little, but the time will still be longer as the user will have to download more data). If you're referring to pngs in general having a bigger filesize if they're transparent, I don't think it affects them that much. The png format stores the alpha channel for every pixel even though it's fully opaque.
     
    ricky92, Aug 3, 2009 IP
  4. zartworkdesigns

    zartworkdesigns Peon

    Messages:
    115
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    here is the code to fix the transparency issue:

    <!--[if lt IE 6]>
    <script type="text/javascript" src="js/unitpngfix.js"></script>
    <style type="text/css">
    .clearfix {height:1px;}
    </style>
    <![endif]-->

    and then get unitpngfix from here: http://labs.unitinteractive.com/unitpngfix.php
     
    zartworkdesigns, Aug 3, 2009 IP
  5. finsofts

    finsofts Active Member

    Messages:
    79
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    63
    #5
    Thanks a lot for the valuable reply all you friends commented.
     
    finsofts, Aug 4, 2009 IP
  6. cignusweb

    cignusweb Peon

    Messages:
    147
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #6
    use this

    <!--[if lt IE 6]>
    <script type="text/javascript" src="js/unitpngfix.js"></script>
    <style type="text/css">
    .clearfix {height:1px;}
    </style>
    <![endif]-->

    var arVersion = navigator.appVersion.split("MSIE")
    var version = parseFloat(arVersion[1])

    if ((version >= 5.5) && (document.body.filters))
    {
    for(var i=0; i<document.images.length; i++)
    {
    var img = document.images
    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=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
    + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
    + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
    img.outerHTML = strNewHTML
    i = i-1
    }
    }
    }

    Paste between head
     
    cignusweb, Aug 4, 2009 IP