Using jQuery animate CSS opacity fade and @font-face gives Internet Explorer very ugly font rendering?

前端 未结 7 1107
北荒
北荒 2021-02-09 15:58

I\'m working on a site with HTML/CSS/jQuery that is trying to act like a Flash site. I\'ve had to use @font-face to get the desired font to work. The client wants the fade in of

相关标签:
7条回答
  • 2021-02-09 16:14

    IE doesn't support opcity properly. read more here JQuery IE <div> opacity problem and here jquery IE Fadein and Fadeout Opacity and here http://icant.co.uk/sandbox/msieopacityissue/

    0 讨论(0)
  • 2021-02-09 16:16

    As mentioned in other answers, jQuery uses the IE-only CSS property filter for opacity in Internet Explorer. It is the use of this property that causes the text rendering problems.

    If you remove the CSS filter when your animation is complete then the anti-aliasing on the text will be restored:

    $('#site').animate({opacity: '1.0'}, 1000, function() {
      $(this).css('filter', 'none');
    });
    

    It will still look jagged while the animation is in progress, but it may not be noticeable if the animation is quick.

    (This was a known jQuery bug and has since been fixed: http://dev.jquery.com/ticket/6652)

    0 讨论(0)
  • 2021-02-09 16:17

    I had the same problem where the fonts look all jagged if I fade in the element. I tried setting the background and found out that it works if I set an opaque background (like #fff) AND set opacity to 0 using jQuery.css(). If I only set opacity to 0 in the stylesheet, it doesn't work. I used fadeTo instead of Animate.

    This works in IE8 for me, I haven't tried IE7 though.

    Try this in stylesheet:

    .fader {
    background: none repeat scroll 0 0 #fff;
    opacity: 0;
    }
    

    And this in JS:

    $('.fader').css('opacity', '0').fadeTo(300, 1);
    
    0 讨论(0)
  • 2021-02-09 16:25

    I had this problem, setting the background-color explicitly on the element fixed the problem.

    This link describes the problem

    0 讨论(0)
  • 2021-02-09 16:26

    I struggled with the cleartype / opacity problem too. I discovered that if the element I want to fade has a solid color background set (css background-color property), the text will render correctly during - and after - fading. So if you don't need a transparent background for the text you can use this workaround. Testet in IE7 only.

    0 讨论(0)
  • Yeah its the opactiy in IE. behind the scenes jQ uses the activeX control to simulate this but that leads crazy things when used in conjunction with transparent png's and type placed over it when the elements are animated.

    0 讨论(0)
提交回复
热议问题