Why is Firefox so bad at resizing images?

前端 未结 7 867
忘掉有多难
忘掉有多难 2020-12-02 14:19

On the left is the original PNG and on the right are versions reduced to roughly half the orignal size using and height. See [Link re

7条回答
  •  伪装坚强ぢ
    2020-12-02 14:55

    I know this is late, but you can trick firefox into rendering the image better by applying a oh-so-slight rotation. I tried to translate() the image to get the same effect... to no avail.

    CSS

    .image-scale-hack {
        transform: rotate( .0001deg );
    }
    

    Javascript

    if( "MozAppearance" in document.documentElement.style ) {
        $('.logo img').addClass('image-scale-hack');
    }
    

    I avoid browser sniffs at all cost. I borrowed this sniff from yepnope.js and I don't feel bad about it.

    Also noteworthy, this same trick can be used to force sub-pixel image rendering in both webkit and firefox. This is useful for very slow animations - best explained by example:

    http://jsfiddle.net/ryanwheale/xkxwN/

提交回复
热议问题