简体   繁体   中英

How to change the style color of svg via css

I am currently building my first website and wanted to implement some svg's. I downloaded some and changed them up a bit with inkscape. The color for the svg is saved like this:

<path
     d="M 44.00,166.00 ..."
     style="fill:#000000;" />

is there a way to change the color with css. For example if i hover over it it changes the color?

Thanks for any help in advance

You probably have it surrounded with <svg> so it would be something like:

<svg class='icon' [...]>
   <path d="M 44.00,166.00 ..."
     style="fill:#000000;" />
</svg>

Then you can change it with:

.icon path {
  fill: red;
}

Notice that it's not the SVG that gets fill but path inside the SVG element.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM