Is there any way to manage SVG inline well?
I'm trying to use img
tag with SVG
, but CSS
can't control the hover style.
I wish to make HTML
more simple, not so many inline SVG.
Is there any way to manage SVG inline well?
I'm trying to use img
tag with SVG
, but CSS
can't control the hover style.
I wish to make HTML
more simple, not so many inline SVG.
The SVG has to be inline in the DOM to be styleable via CSS.
You can achive this by using an SVG injector, that replaces the <img>
tag with the SVG.
For example with SVGInject you can simply add the SVG like this:
<img src="image.svg" onload="SVGInject(this)" />
The attribute onload="SVGInject(this)"
makes sure that the injection is done after the SVG has loaded.
Disclaimer: I am one of the authors of the mentioned SVG injector.
You can convert your svg file into a font so that you can apply more hover styles that you want. I wish this helps. Try going to this site icomoon.io