I'm currently playing around with embedding some basic SVGs inline with my CSS as data URI - similar to what is discussed here.
All this works fine except when I try and have a class which targets one of the inner paths:
.alter {
fill:red;
}
.caretDown {
background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M11 10.07h-5.656l5.656-5.656v5.656z' class='alter' /%3E%3C/svg%3E");
}
Now this doesn't seem to work but if I do this as a plain SVG in my HTML it works fine:
<body>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">
<path d="M11 10.07h-5.656l5.656-5.656v5.656z" class="alter"/>
</svg>
</body>
Ultimately I'm trying to embed the SVGs in this way so that I can use them as background images (seems to work better when inlining with text) and I'm wanting to control things via a class so that I can change the color by switching out targeting/scoped selectors (where dark
and light
are applied to the body as a theme):
.dark .alter {
fill:red;
}
.light .alter {
fill:red;
}
I have some theories around why this isn't working but I can't find anything concrete as to why.