Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firefox not rendering svg properly

Tags:

css

firefox

svg

I came with this issue in Firefox, or maybe I'm using something wrong, but I use svg images like this:

<img src="image.svg" alt="some image">

And the browser rendering them like this:

enter image description here

I can have them like .png and it works fine, but I need them in .svg

Update with SVG source

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24" height="24" viewBox="0 0 24 24">
    <defs>
        <path id="a" d="M13.333 9.333V7.746c0-.717.159-1.08 1.271-1.08H16V4h-2.33c-2.853 0-3.795 1.308-3.795 3.554v1.78H8V12h1.875v8h3.458v-8h2.35L16 9.333h-2.667z"/>
        <path id="c" d="M0 0h24v24H0z"/>
    </defs>
    <g fill="none" fill-rule="evenodd">
        <mask id="b" fill="#fff">
            <use xlink:href="#a"/>
        </mask>
        <use fill="#000" xlink:href="#a"/>
        <g mask="url(#b)">
            <use fill="#232323" xlink:href="#c"/>
        </g>
    </g>
</svg>

Update 2

Tried to move the fill attribute from <mask> to its child element <use> just like in this question, and didn't fixed the issue. I'm using Firefox 55.0.3.

like image 693
cs.matyi Avatar asked Sep 20 '17 08:09

cs.matyi


People also ask

Does Safari support SVG?

SVG (basic support) is Fully Supported on Safari 12, which means that any user who'd be accessing your page through Safari 12 can see it perfectly.

How do I save a SVG file in Firefox?

Firefox (menu/Alt or Ctrl + S), then choose the "just SVG" option in the dropdown menu. Internet Explorer (get Firefox or Chrome, its about time!)

Does Firefox support SVG images?

Firefox supports svg. You can use this HTML code and it will work in firefox.


1 Answers

I don't know why FF is having a problem with this file. You may want to report this as bug to them.

Luckily there is a simple fix. Get rid of those somewhat unnecessary masks that Illustrator adds.

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24" height="24" viewBox="0 0 24 24">
    <path d="M13.333 9.333V7.746c0-.717.159-1.08 1.271-1.08H16V4h-2.33c-2.853 0-3.795 1.308-3.795 3.554v1.78H8V12h1.875v8h3.458v-8h2.35L16 9.333h-2.667z"/>
</svg>
like image 131
Paul LeBeau Avatar answered Sep 18 '22 11:09

Paul LeBeau