Can I change the fill color of an svg path with CSS?

后端 未结 8 1696
抹茶落季
抹茶落季 2020-11-28 21:09

I have the following code:

  
     

        
8条回答
  •  悲哀的现实
    2020-11-28 21:16

    Yes, you can apply CSS to SVG, but you need to match the element, just as when styling HTML. If you just want to apply it to all SVG paths, you could use, for example:

    ​path {
        fill: blue;
    }​
    

    External CSS appears to override the path's fill attribute, at least in WebKit and Gecko-based browsers I tested. Of course, if you write, say, then that will override external CSS as well.

提交回复
热议问题