I have in css (generated by sass) variable called --secondary
and it’s value is red(#f00)
I want to create more variables for opacity like --secondary-100
, --secondary-90
, …
I used color-mix
in oklab, so this is the code:
setTimeout(_ => {
document.querySelector('div').style.cssText += `--secondary:#f00;`
},100)
div {
width:100px;
height:100px;
--secondary-100: color-mix(in oklab, var(--secondary) 100%, transparent 0%);
background-color: var(--secondary-100);
}
<div></div>
as you can see the div is transparent not red
( if you see it red that mean i didn’t recreate the problem the problem stile exist in the real firefox site )
i tried it in firefox and this is the result
in devtools i just wrote the same thing contains in the variable --secondary-100
out of it
and it suddenly works idk where is the problem or is it a well known problem and I’m living under my rock
btw this variables and colors is user choice and not static so i can’t just write them my self and the best i can do is to use javascript to deal with those colors and save them directly without using color-mix
2
Answers
it just worked when i replaced the :root with * idk why or how but in chrome devtools it appears that the variable declearied in the :root wasn't declearied in the children
You have to specify the method parameter. It is the first parameter.