Answer the question
In order to leave comments, you need to log in
How to use SVG sprite to connect images through background?
I would like the easiest way. Just throw these shapes in SVG into a separate file like this:
<svg display="none" xmlns="http://www.w3.org/2000/svg">
<defs>
<symbol xmlns="http://www.w3.org/2000/svg" id="x1" viewbox="0 0 16 16">
<circle fill="none" stroke="#b4b4b4" stroke-miterlimit="10" cx="8" cy="8" r="3.5"/>
</symbol>
<symbol xmlns="http://www.w3.org/2000/svg" id="x2" viewbox="0 0 16 16">
<circle cx="8" cy="8" r="3.5"/>
</symbol>
</defs>
</svg>
<div class="icon-1"></div>
background: url(sprite.svg#x2)
Answer the question
In order to leave comments, you need to log in
Sprites are implemented like this . Plus minus, you can not use symbols, or even defs, but simply call by id.
It is possible, but I do not recommend for the sake of cross-browser compatibility, to call from an external file, it is worth embedding this goodness in the document for manageability.
More structured information can be found here .
In order to be able to control SVG from styles, you need to register it either inline - throw the code of the svg file into HTML or connect the SVG file to HTML through object.
Otherwise, they cannot be controlled through css.
And you can insert SVG into SVG.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question