Blurry SVG images in chrome for Android

前端 未结 4 1649
误落风尘
误落风尘 2020-12-08 05:26

To escape the hell of different pixel densities in mobile phones, I use SVG-files as background images in my css.

Chrome for android seems to render inline-svg

4条回答
  •  情歌与酒
    2020-12-08 05:55

    As other answers have pointed out in this issue and other similar issues SVG's rendering is problematic in chrome and the native android web browser. It's a known chrome / native browser issue.

    After looking at many solutions over a number of days I stumbled on this workaround by chance. The trick is to embed text inside the SVG file, this can be single transparent character.

    For Example, add this (or similar) to your SVG files.

    a
    

    Without investigating the actual chrome source or processes I can only assume that by embedding text it is forcing the SVG to be re-rendered on scale-up for the high dpi devices.

    This solution (on the browsers I've been able to test on Android/Chrome) works no matter how the background-image element is used, rotations, fixed position etc. And even seems to be clear under zoom.

    Enjoy!

提交回复
热议问题