I have CSS variable called --size which is set with javascript. Its value will be 0 or any whole number.
I wish to create a new CSS variable using the calc function. I want the value of this new variable to be either 0 or 1.
- If
--size= 0 then the new variable = 0 - If
--size> 0 then the new variable = 1
I can use the below code to achieve this:
--new: calc(var(--size)/(var--size))
But when --size = 0, this does not work.
Is there a way that I can adjust my calculation to achieve 0 or 1 dependent on the value of the variable?