Transparent PNG animate problem on Internet Explorer

前端 未结 10 2135
误落风尘
误落风尘 2020-12-29 16:05

CSS Code:

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


        
10条回答
  •  攒了一身酷
    2020-12-29 16:50

    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:

    Of course, no version of IE supports the CSS opacity property yet, so jQuery instead applies the opacity by exploiting the IE-proprietary AlphaImageLoader filter. This ends up being the root cause of the (seemingly well-known) bug. The suggested fix is to apply the transparency to the parent element instead, but I’ve had little success with that workaround.

    What did work was a little library called DD_belatedPNG that applies PNG transparency via VML instead of AlphaImageLoader. It’s designed for IE6, but it works just fine in IE7 as well. For IE8, I was forced to throw out an X-UA-Compatible meta tag and step IE8 down to IE7 mode for this particular page.

    It’s still not perfect. I noticed a faint white bounding box poking through at lower opacities that forced me to slightly adjust hover effects for all versions of IE. But you know, for all that, it’s darn well good enough.


    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...

提交回复
热议问题