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?
There is a library that supposedly solves this problem: jCSML. I have tried it and it works to animate transparent pngs in IE 7+.
filter:''
hack does not work with current jQuery (1.6.1) anymoreThanks to Julien for his answer, it lead me in the right direction!
However, I was still getting a gray halo around the text during the image opacity transition. It looked fine when it was static, but it was still creating a strange slight grey halo (IE 8). I fixed it by changing to the values below.
Also, I had to separately declare the "zoom: 1" property, because IE 8 was just smashing that value to the end the
background
property. Same thing withbackground-color: transparent;
IE sucks.My working CSS:
Note that I had to change
endColorstr=#00FFFFFF
toendColorstr=#FFFFFFFF
.To reiterate Julien, this solution came from Viget.com.
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.
Hey, looks like Sampson might have been wrong. See Dave Shea's post on this: http://mezzoblue.com/archives/2010/05/20/ie8_still_fa/
I'm just going to dump three paragraphs of the solution here:
Mmmhmmm... It's odd that this solution didn't pop up when this question was asked 6 months ago. Sure, this blog post didn't exist, but the solution had been around for quite a while. Strange that nobody noticed it...
Interesting note: jQueryTOOLS uses a GIF in all IE versions as bugfix for tooltips. Demo