Font looks blurry after translate in Chrome

前端 未结 10 1454
逝去的感伤
逝去的感伤 2020-12-30 20:05

EDIT 2016-07-04(Since this question is getting popular): This is a bug in Chrome. Developers are actively working on a fix.

EDIT 2017-05-14<

10条回答
  •  误落风尘
    2020-12-30 21:04

    The only solution that worked for me:

    Translates can cause blur due to result not being rounded to the nearest pixels, so rounding the div height to an even number fixes it.

    We can't do it in CSS as it doesn't know yet its final height, so we have to do it after rendering. Using Jquery is a breeze:

    $(window).on("load", function() {
        if($('.popup').height()%2==1) $('.popup').height( 2*Math.round($('.popup').height()/2 ) ) ;
        if($('.popup').width()%2==1) $('.popup').width( 2*Math.round($('.popup').width()/2 ) ) ;
    });
    

    Credits: https://stackoverflow.com/a/57382347/1136132

提交回复
热议问题