Problems with the connection of the sprite in Firefox, like other browsers may arise for many reasons, but more on that later.
Connecting the sprite in html via the <object> :
<object type="image/svg+xml" data="http://svgshare.com/i/2X7.svg#usd-usage" width="200" height="200"> </object>
The snippet does not work, but if you save this code in a separate html file, it works in Firefox and Chrome.
Connecting the sprite in html through the <img> :
<body> <img src="http://svgshare.com/i/2X7.svg#usd-usage" width="200" height="200" alt="image description"> </body>
Connecting the sprite in html using background-image :
<body> <style> .container { width:200px; height:200px; background-image: url("http://svgshare.com/i/2X7.svg#usd-usage"); } </style> <div class="container"> </div> </body>
Please note that for all methods of connecting svg, as a separate file in html , the width and height are indicated in one way or another. Firefox is primarily sensitive to this. More details about other ways to connect svg files here.
- Another source of sprite visibility problems is that sprite itself is often
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <defs> <style> .sprite-symbol-usage {display: none;} .sprite-symbol-usage:target {display: inline;} </style> <symbol viewBox="0 0 500 500" id="usd"> <path d="m 145,312 c -2,69 31,100 104,102 78,1 113,-34 109,-101 -6,-58 -62,-73 -106,-79 -48,-17 -99,-25 -99,-95 0,-48 32,-79 99,-78 60,0 97,25 96,84" style="fill:none;stroke:#000000;stroke-width:40" /> <path d="m 250,15 0,470" style="stroke:#000000;stroke-width:30" /> </symbol> </defs> <use id="usd-usage" xlink:href="#usd" class="sprite-symbol-usage" /></svg>
Because of the styles: .sprite-symbol-usage {display: none;} picture will not be visible. Some pair of <defs>.. </defs> or <symbol>.. </symbol> clearly superfluous, since they perform the same function - hide the image before calling with the use command
Since you cannot edit the file on another resource, it is better to download it and put it in order:
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 500 500" > <symbol viewBox="0 0 500 500" id="usd"> <path d="m 145,312 c -2,69 31,100 104,102 78,1 113,-34 109,-101 -6,-58 -62,-73 -106,-79 -48,-17 -99,-25 -99,-95 0,-48 32,-79 99,-78 60,0 97,25 96,84" style="fill:none;stroke:#000000;stroke-width:40" /> <path d="m 250,15 0,470" style="stroke:#000000;stroke-width:30" /> </symbol> <use id="usd-usage" xlink:href="#usd" class="sprite-symbol-usage" /> </svg>
- If you will reuse the sprite, and it is designed specifically for this, there will certainly be questions about styling
For a solution, you can look here , here and here.