How to create PNG transparency work in IE 6

firefox-viewie6-view

Let’s take a look at the difference of PNG images (with transparency) above on Mozilla Firefox and Internet Explorer 6
If you inserting images in PNG format with transparancy will leave you with a white background when saw in Internet Explorer 5 or 6.

It makes your image looks not good and this is really the last thing any web designer would want on their website.
Don’t worry about that, I’ll give you a solution on how to solve this.

Solution:

Create a container to store your image. In this case I use a <div>.
Create your <div> inside your <body>, just like this:

<body> <div class=”flower”></div> </body>

Next, create a <style> if you dont have one. Make sure they are between your <head> </head>. Put the following css inside:

<style>
body {background-color:#000}
div.flower {background:url(flower-transparent.png) no-repeat; height:100px; width:100px}
</style>

The CSS codes above displays your PNG image in a <div>. Works fine for Mozilla Firefok, but not for Internet Explorer. To get it working cross browser, create another set of css just for Internet Explorer right below your <style> </style>.
Insert the following codes:

<!–[if gte IE 5]>
<style type=”text/css”>
div.flower {
background:none;
filter:progid:DXImageTransform.
Microsoft.AlphaImageLoader  (src=’flower.png’ ,sizingMethod=’crop’);
}
</style>
<![endif]–>

Your IE should now give you a perfect blend like the picture below.

ie6-view-after

4 tanggapan untuk “How to create PNG transparency work in IE 6

  1. Summer Camps Balas

    Best you should change the blog subject Create PNG transparency work in IE 6 with css | Gusdwi dot Info to more generic for your webpage you write. I loved the post all the same.

Tinggalkan Balasan

Alamat email Anda tidak akan dipublikasikan. Ruas yang wajib ditandai *