I am defining a color set for a small project. I want to define custom properties for a range of hsla() colors but be able to vary the opacity of those colors. Should I be able to do something like this:
:root {
--clr-900: hsla(36, 83%, 0%, var(--opacity, 1));
--clr-700: hsla(36, 83%, 30%, var(--opacity, 1));
--clr-300: hsla(36, 83%, 70%, var(--opacity, 1));
--clr-200: hsla(36, 83%, 85%, var(--opacity, 1));
--clr-100: hsla(36, 83%, 100%, var(--opacity, 1));
}
The theory is if I apply just the property, I get an opacity of 1. If I set the --opacity custom property, it would change the opacity:
.test1 {
background-color: var(--clr-900);
// hsla(36, 83%, 85%, 1)
}
.test2 {
--opacity: 0.65;
background-color: var(--clr-900);
// hsla(36, 83%, 85%, 0.65)
When I try this, I always get the fallback value (1) rather than resolving var(--opacity)
when present.