Replies: 2 comments 2 replies
-
That’s not possible. CSS variables are dynamically scoped. |
Beta Was this translation helpful? Give feedback.
1 reply
-
the beauty of using custom style properties is that you can override them and apply dynamically. :root {
--span-color: blue;
}
p > span.special {
--span-color: red;
}
span {
color: var(--span-color);
} This color rule will be set as a very low priority and allow other rules to override it easily. Instead, you should do like this. default-color = #047308
:root {
--test-color: default-color;
} and that |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The problem:
If you define a test-color or test-spacing for example and assign it to stylus variables:
This works just fine and you're able to manipulate the color/size dynamically with javascript.
But the moment you try and add for example rgba, hsla, ... for the colors or if you try and multiply the spacing you get a error cause the css variable isn't compiled to what stylus can understand.
example:
Possible solution
Make sure the css variable is compiled before other infleunces happen to the variable?
I'm not exactly sure the what's or how's..
Beta Was this translation helpful? Give feedback.
All reactions