Transparent PNG, IE and FX compatible

The best practice of transparent image is always use .png instead of .gif .

.gif should used for animation, because .png have more color and do more elegant transparency. Static image should always use .png .

But when you view your transparent .png in IE, It will have a background color.

This is another problem caused by mighty IE…

Here is how you fix it by CSS, there are many other fix though.

I like this CSS fix because it follows the separation of content and style rule.


#ID {
background-image: none;
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="resources/images/UL_corner.png", sizingMethod="scale");

Others Browser

html>body #ID {
background-image: url(../images/UL_corner.png);

Possible value for sizingMethod:

crop Clips the image to fit the dimensions of the object.
image Default. Enlarges or reduces the border of the object to fit the dimensions of the image.
scale Stretches or shrinks the image to fill the borders of the object.

Keep two things in mind:

1. The ordering needs to be follow, IE then other browsers.

2. The reference link syntax is different for filter and normal CSS. It follows the Javascript Style


Transparency style – opacity

I really want to make transparency on my website

because it is lightweight and the effect is charming.

it is done by CSS attribute opacity.

I like to keep my web compatible for FF and IE.

I will go straight to the code.

opacity: .5;       //for FF
filter: alpha(opacity = 50);      //for IE
height: 50px;
width: 50px;

1 means visible, 0 means invisible. same for 100~0 in IE.

opacity from 1 to 0 is W3C standard.

This is why I don’t like IE, no standard at all and many more to come.

You’ll see what I mean.

REMARK: This effect needs height and width to work together.