Tim Rinkel
KPCKevin Powell - Community
•Created by Tim Rinkel on 10/6/2024 in #front-end
Using `:first-of-type` with data attribute values?
Should I be able to use a CSS selector like
[data-progress="pending"]:first-of-type
?
Background: I have a series of elements, each with a [data-progress='pending'|'done']
attribute. All elements start as pending
and change to done
when they finish (they complete in order). I want to set a darker background color for all of them to start. The first with a pending
state I want to give a white background. When that one changes to done
it would turn green and the next element would turn white. The result I'm getting is as if :first-of-type
only recognizes the [data-progress]
attribute itself and not the value. Is this the way it works or do I need to be looking for a bug in my code somewhere. I've Googled and MDN'ed and haven't been able to find an answer.
Code Example: This is a simplified example of what I'm doing:
So, the question is, should :first-of-type
work with data attribute values like this?
Thanks!14 replies
KPCKevin Powell - Community
•Created by Tim Rinkel on 1/13/2023 in #front-end
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.
15 replies