+ 1

Can I use function for variables values in CSS?

Good day for everyone who read me☺️ I’m trying to practice CSS making a watch🕐 and I want to use variables to set sizes of elements. In order to do that, I think it’s better when I change one element, all elements change too. So, I wonder 1️⃣if I can use the function calc() to set values for variables and 2️⃣if it’s possible to make one variable dependent of other one. Is this code right?: :root { —boxSize: 35rem; —watchSize: calc( var(—boxSize)*92.85% ) } Thank you very much for everyone who can help me with this. 😁

3rd Oct 2020, 3:27 AM
Isaac L. Muñoz
Isaac L. Muñoz - avatar
2 odpowiedzi
+ 5
Yes but you need to add space b/w the * operator.
3rd Oct 2020, 4:09 AM
Aswajith
Aswajith - avatar
0
Last answer worked. Thanks, Aswajith!🤗 Just one thing to say: 92.85% was changed for 0.9285
4th Oct 2020, 12:57 PM
Isaac L. Muñoz
Isaac L. Muñoz - avatar