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

前端 未结 2 1708
余生分开走
余生分开走 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"

    0 讨论(0)
  • 2020-12-28 12:20

    You can use fill="currentColor".

    <a href="#" style="color:red">
    <svg fill="currentColor"> ...</svg>
    </a>
    
    0 讨论(0)
提交回复
热议问题