How do I change the colour of an SVG image in a CSS content property? -


i'd use svg image css sprite through content property, bootstrap-style, so:

i.rectangle-image {   content: url(rectangle.svg); } 

and here's svg:

<svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 100 100">   <rect x="10" y="10" width="80" height="80"/> </svg> 

and proposed html:

<div><i class="rectangle-image"></i> hello, world!</div> 

i'd able re-colour svg in application, example have icon appear purple in locations, , white in others. know can accomplish having 3 different svg files (or data uris) fill attribute set differently on <rect> tag, i'm wondering if there's way me through css in html?

i've tried adding fill attribute i.rectangle-image selector, doesn't work.

i've looked @ this answer , it's not quite want. suggest embedding svg throughout page, , i'd prefer via css content if possible. thoughts? out of luck?

if use css content facility you're loading svg data image. privacy reasons can't affect how image displayed using external css or javascript.

if want change contents of svg data you'd either have load via <object> or <iframe> tag or put inline in html file.


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -