CSS not applied to SVGs
See original GitHub issueSee this demo for an illustrated example.
When inline SVGs are styled using CSS the properties are not rendered.
My example above shows how an SVG that includes a defined fill property as:
<path fill="red" ...
But is then overridden in the browser using the CSS:
path {
fill: green;
}
will render in the browser as a green path but once converted to a canvas using html2canvas the property is lost and is instead rendered as red.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:7
Top Results From Across the Web
How to style SVG with external CSS? - Stack Overflow
Let's say you have 10 SVGs you want to style. Now you need to copy in a reference to the CSS into all...
Read more >SVG Properties and CSS
There are many Scalable Vector Graphics (SVG), but only certain attributes can be applied as CSS to SVG. Presentation attributes are used to ......
Read more >SVG and CSS - SVG: Scalable Vector Graphics | MDN
This page illustrates the application of CSS to the specialized language for creating graphics: SVG.
Read more >Styling — SVG 2
Elements in an SVG document can be styled using CSS. Most visual characteristics and some aspects of element geometry are controlled using CSS...
Read more >Styling And Animating SVGs With CSS - Smashing Magazine
Most CSS selectors can be used to select SVG elements. In addition to the general type, class and ID selectors, SVGs can be...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Jerther you saved my day, thanks a lot! I confirm this works, here’s a Typescript version if anyone needs it:
Here’s a version of the fix that does not rely on external libraries:
Try here with jsFiddle