A
A
Alexey Nikolaev2017-06-04 19:30:42
css
Alexey Nikolaev, 2017-06-04 19:30:42

How to color an SVG icon?

Good evening.
There is an SVG symbol which is further inserted and used via use. In general, a standard set. But there is one "but" - it does not react to the color property, at all. The icon is simply a ring created through the path tag (yes, I know that path is not used for circles, but the icons were made through illustrator by converting paths from Photoshop, and I don’t want to mess around with the generated code - we work with what we have) .
I read that it is necessary to remove the fill, stroke attributes, because they take precedence over css. OK well. But the behavior becomes incomprehensible and inadequate:
- if I remove the stroke from the path element, all visible elements disappear
- if I remove the fill attribute too, I get a solid circle, but I need a ring
- in all the above cases, nothing reacts to the css-rule with color
How to color the icon through css? Fiddle of the whole thing.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Danila, 2017-06-04
@Heian

https://jsfiddle.net/nfkub464/
- in all of the above cases, nothing reacts to the css-rule with color
everything is correct, because it is responsible for the color of the text
if you need to control the color through color, you can do this
https://jsfiddle.net /cfdg0q0n/1/

F
Froggyweb, 2017-06-04
@Froggyweb

It can be so if necessary
.

icon {
  color: red;
}

svg use {
  fill: currentColor;
}

just need to remove fill="none" in SVG

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question