Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transparent PNG animate problem on Internet Explorer

CSS Code:

#btn{
  background: url(transparent.png) no-repeat;
  filter: alpha(opacity=0);
  -moz-opacity: 0;
  -khtml-opacity: 0;
  opacity: 0;
}

JavaScript/jQuery:

$("#btn").animate({opacity:1,"margin-left":"-25px"});

I don't have any problem with the code above on Firefox, Chrome and others. But it does not work on any version of Internet Explorer.

The problem is the PNG image is rendered strange, background of the transparent PNG looks black. When I remove opacity effect, there is no problem.

What is the solution?

like image 793
goksel Avatar asked Mar 04 '10 03:03

goksel


3 Answers

For me it worked to just include the filter property with blank value in jQuery's .animate()function

Maybe this will work for you, too.

$("#btn").animate({opacity:1,"margin-left":"-25px", filter:''});

Additionally you might have to remove the filter property from your button's CSS.

like image 136
Björn Kaiser Avatar answered Nov 03 '22 17:11

Björn Kaiser


filter:'' hack does not work with current jQuery (1.6.1) anymore

like image 22
nicmare Avatar answered Nov 03 '22 19:11

nicmare


There is currently no solution for this that I'm aware of. Just have to wait for IE to catch up with the rest of the world. I had to abandon such a feature in a recent project just days ago. You unfortunately cannot have a feathered-edge PNG with IE fading in and out with jQuery.

like image 30
Sampson Avatar answered Nov 03 '22 17:11

Sampson