set svg background color css

29

/* You can use CSS masks, With the 'mask' property, you create a mask that is applied to an element. */
background-color: red;
-webkit-mask-image: url(icon.svg);
mask-image: url(icon.svg);
If you are trying to use and SVG directly on CSS with url() like this;

a:before {
  content: url('data:image/svg+xml; utf8, <svg xmlns="http://www.w3.org/2000/svg" x="0" y="0" viewBox="0 0 451 451"><path d="M345.441,2...

You should encode the # to %23, otherwise it won't work.

<svg fill="%23FFF" ...

Comments

Submit
0 Comments