Using CSS custom property in inline SVG
I'm trying to replace a single character on a website with an inline SVG. I'm basing what I'm doing on Kevin's video "Basic, Intermediate & Pro animated hamburger icons". The main difference at this point is I'm doing it in a pseudo element:
I have the SVG working finally, but I can't get the custom property to apply. If I replace it with an actual color, it works. Is this just not possible as part of the content of a pseudo element or am I doing something wrong? I'm hoping for the latter.
8 Replies
can you put a minimal demo in codepen?
I've not tried custom props in a data: string before, I'd have to play a bit
Other option I can think of off hand is trying with a fallback
fill="var(--clr-neutral-100, currentColor)"
then you can also try setting color on the parent if that is an option
another thing you could try is having the custom prop on the parent level
assuming that clr-neutral is set in :root?clr-neutral
is set in :root
and works outside of this pseudo element.
currentcolor
is an interesting thought. I tried it a few different ways but it didn't seem to make a difference.
Here's the pen I was playing with: https://codepen.io/t_rinkel/pen/rNrmzBq .thanks for the pen give me a bit and I'll play around.
Don't think it is possible within a url(). But, I just came up with this solution (kinda proud 😁)
Make it a mask
@markboots. That certainly seems to work on my end. You have plenty to be proud of ‼️ I'll give it a shot in the real site. Thanks!
Yep, that works on the site. Now I just need to tweak it back into place. Thanks!!
nice. you can use mask-size and mask-position for that (also with -webkit)
what wizardry is this
sorry I got sidetracked with helping a friend >.>;;