StylizedWeb

Subscribe to our updates:

A Design, WordPress and Tutorials Blog.

Dedicated to helping you learn the art and science of the web.

PNG transparency issues

If you are CSS coder, you've probably ran in to png transparency problems many times. Even Microsoft is having problems with it http://runonce.msn.com/runonce2.aspx open in IE6. So I'll tell you few problems and solutions I've handled so far.

First one is if you need just simple transparent image, without some special needs for example backgrounds etc. The solution would be png fix. I've used it many times but it has lots of faults, for example with padding, margins and absolute positioning. Sometimes i can mess up the rest of your JavaScript files, but anyway very useful script. You can download it here http://homepage.ntlworld.com/bobosola/pngfix.js and just include it in your <head> tag

PNG

<!--[if lt IE 7.]>
<script defer type="text/javascript" src="pngfix.js"></script>
<![endif]-->

The second one can partly handle issues from first and it's pure CSS solution. I mostly use this for backgrounds, because if your path for a background is from CSS file then png fix can't handle it.

PNG

.someelement {
background-image: url(images/image.png);
}
 
* html .someelemen {
background-color: #333;
back\ground-color: transparent;
background-image: url(images/blank.gif);
filter: progid:DXImageTransform.Microsoft.
AlphaImageLoader(src="images/image.png", sizingMethod="scale");
}
 

I found this very useful, and also when you add some hover effects for example some color or other image. You can see live example here
NOTE: This simple hover is just example and it doesn't work in IE6

.someelement:hover {
background: #333;
}
 
.someelement:hover {
background-image: url(images/image2.gif);
 
}
 

Only problem I had with this was with <a> tag, link just don't work (when it's in div with this kind of background) and i don't know why (talking again for IE6). And only solution i could think of was to place another absolute div over it for the links, content etc... Yes i know it's not elegant but it works if content is not dynamic.

Luckily more and more people are starting to use IE7, and i must say i have recently switched too, i had to have IE6 because of testing my code and when i found out for Multiple IE program I switched immediately ;)

Leave a comment on Stylized Web Have some feedback? Leave a comment

92 Comments So Far

  1. Nice, I will try transparent pictures next time :-)

  2. I could have workaround using IE filters but that defeats the purpose of image caching as images are filtered per instance not per image.

    Instead I went the simple route. IE6 uses PNG8 transparency just fine. It is just index transparency not alpha transparency which sucks.

    Solution use photoshop to save PNG24.

    Then open with fireworks and save as PNG8 with alpha transparency. (photoshop wont do this.)

    Final Result. Beautiful alpha on modern browsers. And ugly index transparency (GIF Style) on IE6 with no CSS hacks.

    Trey (Web Standard CSS) Brister

  3. Hi. Thank you for your CSS Hack. But does it work for old navigators ?

  4. Play Free Online Games, sports games, massive multiplayer games, action games, puzzle games, flash games and more, casual games.

  5. INTERFERENCE FOREIGN TRADE web environment
    We offer all products with the best service initiatives, improving the quality of service the products you ihtal web environment provides a detailed way. Category dedicated to the product range with the desired structure, providing convenient access to products from our web site to review the order or request for information from the contact form to reach us

  6. When I want an image with a transparent background and knowing that PNG’s don’t work in IE6, I will save the image as a GIF with no background and that works just the same as a PNG.

  7. Thank you. It’s good for me.

  8. I love this blog, thanks

  9. Thanks for your work and for your comment

  10. By Razzaq Bashir posted on August 29, 2009 at 11:16 am

    This is a great script to solve the .PNG issues in IE 6.

  11. Nice looking site you’ve got here. Thanks for the tip!

  12. автор, хорошо пишешь, продолжай в том же духе

  13. Good Script. thank u :-)

  14. Nice script and solution.

  15. Thanks for the script. Looks nice.

  16. Pingback: 10 Best CSS Hacks

  17. Pingback: 10 best CSS hacks - Nagpur Chat Room

  18. this helped me so much! Thank you

  19. this helped me so much! Thank you

  20. Nice, I will try transparent pictures next time

  21. Thanks for really good article. It seems that someone did a great work for all of us. What else I could say? Keep up the good work and don’t be shy :)

  22. Great share and good news. Thanks for your effort. BTW: your site works superb. :)

  23. The second one can partly handle issues from first and it’s pure CSS solution. I mostly use this for backgrounds, because if your path for a background is from CSS file then png fix can’t handle it.

    thank you

  24. Thank you for interesting article

  25. altın cılek

  26. Çok Sağol ya mükemmelmiş

  27. %100 Doğal ve hiç bir yan etkisi olmayan Uzamax’ı keşfedin
    UZAMAX içeriğinde mineral ve vitaminler barındıran, doğal bitkielerden üretilmiş gıda desteğidir. İçeriğinde herhangi bir kimyasal ürün bulunmamakla birlikte tamamen doğal kurutulmuş bitkisel bir karışımdır. Sadece birkaç aylık kullanım kürü sonrasında bile uzamax’ın etkisini hissedeceksiniz.

    Uzamax kullanarak doğal yollarla bünyenize gerekli olan tüm besin, vitamin ve mineralleri vücudunuza almanızı sağlar.izlanda yosun hapı

  28. By Saurav Ganguly posted on March 10, 2011 at 10:26 am

    Thanks a lot

  29. is not easy to put on weight

  30. Thanks There is a great solution, which fixes a lot of issues with ie6 and lower. And implements png transparency.

  31. A beautiful and high quality information.this paper is accurate to be useful. Thanks to the author.

  32. Nice script,
    Thanks for the tip..
    :-)

  33. wooow that was good

  34. Thanks There is a great solution, which fixes a lot of issues with ie6 and lower. And implements png transparency.

  35. By Sowmya posted on September 27, 2011 at 1:08 pm

    What is the solution for direct png images?

  36. Thanks for the usefull info at the blog

  37. Thanks for all the usefull info at your blog

  38. Thanks for the usefull info at the blog :)

  39. A beautiful and high quality information.

  40. In A, B, C, high levels of vitamins and beta carotene barındıran­African Mango, form meets guidelines as well as the effect of contributi­ng to the beauty of your hair and skin. Beta Carotene, to ensure the beauty of the skin, night vision to strengthen the immune system against disorders, a variety of infections contribute to the substance.­Those who want to enter the world healthy and permanent form, which is a product of choice for African Mango, now in Turkey. Because people prefer to use a 100% herbal product that helps people to enter the African Mango form a single product.
    http://www­.africanma­ngosiparis­.com/

  41. Those who want to enter the world healthy and permanent form, which is a product of choice for African Mango, now in Turkey. Because people prefer to use a 100% herbal product that helps people to enter the African Mango form a single product.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>