麥克斯做個不宅的工程師

Maxi’s idiotic programming.

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.

IE

#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

May 15, 2008 , Thursday - Posted by maxi326 | Web | , , , , | No Comments Yet

No comments yet.

Leave a comment

You must be logged in to post a comment.