I use Inkscape for creating svg images and want to know how to use not embedded css rules.
For example
class="rect1"
How to add css like
.rect1 { fill:#ffef00; }
Inkscape's native format is Scalable Vector Graphics (SVG), but it can also open most types of image files, including PDF, JPG, GIF, and PNG.
Here's an example of an SVG in an HTML page that you can style with CSS:
HTML page
<div id="mySvg">
<svg>
<use xlink:href="images/logo.svg#shape" />
</svg>
</div>
The SVG (located at images/logo.svg)
<svg version="1.1" xmlns="http://www.w3.org/2000/svg">
<defs>
<g id="shape">
<rect x="50" y="50" width="50" height="50" />
<circle cx="50" cy="50" r="50" />
</g>
</defs>
</svg>
The CSS
svg {
fill: currentColor;
}
#mySvg {
color: green;
}
See working example: plunker
Notes
fill
attributes in it (fill
should be in the CSS). When making an SVG with Inkscape, it often has a fill:none
or something. You'll have to manually remove those.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With