Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firefox and Opera: SVG & background-size results in bad rendering

I have some elements on a page that use a SVG-file as a background image. It works well in Opera, Chrome and Safari, only Firefox renders the graphics really pixelated.

I already did a search on that topic, there are even some similar questions here on SO:
SVG rendering badly in Firefox
Firefox not anti-aliasing scaled background svg
Firefox SVG graphics blurry

Some suggestions were to not scale the SVG too much using background-size and to give it width="100%" height="100%".

I only scale the SVG by 5%, so that really shouldn't be too much. Adding width="100%" height="100%" was fixing the pixelation a bit, but its still really blurry compared to the other browsers.

What helped was this linked comment: http://coding.smashingmagazine.com/2012/01/16/resolution-independence-with-svg/#comment-573707

Originally the width and height were 22px. Now I've set both to 200px and voilà, the SVG renders as crisp as it should - but now Opera renders it a bit blurred/really bad! Also, when zooming in, the graphic gets 'cut off'. So instead of scaling proportionally, the graphic seems to be upscaled in it's box. Is there any fix for that?

The interesting thing is: As background image for a button, it renders blurred. As background image in an input field, it renders as "overly crisp" I would call it.

like image 274
Sven Avatar asked Nov 13 '22 12:11

Sven


1 Answers

pls add these below element class in your stylesheet

img {
-ms-interpolation-mode: bicubic;
image-rendering: -moz-crisp-edges;
background:transparent; }
like image 80
Web Designer cum Promoter Avatar answered Nov 15 '22 12:11

Web Designer cum Promoter