Relative color from currentcolor
Hello everyone,
On MDN's relative color page (https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_colors/Relative_colors) it's stated that
origin-color
should be any valid color, including currentcolor
.
But when I try to do something like this :
First and second background-color
work fine, but not the third one (see attachment).
Does anyone have any idea if I'm doing something wrong ? Or do I missing something ? :think:
PS: I tried color
with both lower and upper case c
MDN Web Docs
Using relative colors - CSS: Cascading Style Sheets | MDN
The CSS colors module defines relative color syntax, which allows a CSS value to be defined relative to another color. This is a powerful feature that enables easy creation of complements to existing colors — such as lighter, darker, saturated, semi-transparent, or inverted variants — enabling more effective color palette creation.
9 Replies
probably just a feature support issue, not all of these have great support: https://caniuse.com/?search=relative%20colors
I tested it on Chrome and Safari, neither seem to work. 😕
@MaelFr @Jochem is right.
Relative color functions don't support
currentColor
And I apparently just learnt a new way to find this kind of niche bugs
https://wpt.fyi/results/css/css-color/parsing/color-valid-relative-color.html?label=experimental&label=master&aligned
I found it while scrubbing through the specs
Here's a work around that Gemini suggested to me though:
Of course, I know this is very limited, but hopefully, you can use it.
If not, maybe force color-mix to give you something similar to what you want.
But sadly this one won't work though 👇
OK, so the MDN doc is right, just not yet implemented.
Thanks for the answer and the link, that's what I was looking for.
I'll wait a little bit more to be able to use it.
🙏
I just saw* an intent to prototype relative colors this past week so hopefully we wont have to wait too long
I've been low-key using contextual understanding to figure out the shipping process.
Can you explain the process from before a feature is spec'd to when it finally ships to the browsers?