W
W
weranda2020-04-28 08:06:00
css
weranda, 2020-04-28 08:06:00

How to decorate an SVG sprite?

Greetings.
There is such a code (for example, I gave only one element of the sprite):

<svg display="none">
  <symbol id="thing" viewBox="0 0 123 35"">
    <rect x="45" width="35" height="35" />
    <circle cx="17.5" cy="17.5" r="17.5" />
    <path d="M107.5 2L122.655 28.25H92.3446L107.5 2Z" />
  </symbol>
</svg>

<svg class="icon-thing">
  <use xlink:href="#thing"></use>
</svg>

Is it possible to decorate shapes through styles without changing the sprite code and without third-party libraries?
5ea7b9a306bba514962211.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
twobomb, 2020-04-28
@weranda

<svg display="none">
  <symbol id="thing" viewBox="0 0 123 35">
    <rect x="45" width="35" height="35"  />
    <circle cx="17.5" cy="17.5" r="17.5"/>
    <path d="M107.5 2L122.655 28.25H92.3446L107.5 2Z"/>
  </symbol>
</svg>

<svg class="icon-thing">
  <use xlink:href="#thing"></use>
</svg>

#thing rect{
  fill:blue;
}
#thing circle{
  fill:red;
}
#thing path{
  fill:yellow
}

G
godsplane, 2020-04-28
@godsplane

svg { 
fill: red;
 }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question