How do I have an SVG image inherit colors from the HTML document?

前端 未结 2 1711
余生分开走
余生分开走 2020-12-28 11:56

I have a bunch of SVG images that I want to embed in an HTML page, which is styled with CSS.

I want to be able to have elements in the SVG have their color inherited

2条回答
  •  遥遥无期
    2020-12-28 12:07

    HTML uses color whereas SVG uses fill and stroke. You can get fill or stroke to use the value of the color CSS property by using the value currentColor e.g. fill="currentColor"

提交回复
热议问题