MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programming/comments/omvkcc/5_levels_of_using_css_variables/h5o86si/?context=3
r/programming • u/yangzhou1993 • Jul 18 '21
3 comments sorted by
View all comments
13
I feel like (4) misses the point of cascading style sheets:
:root { --color: green; --small-screen-color: red; } div { color: var(--color); } @media screen and (max-width: 768px) { div { color: var(--small-screen-color); } }
Instead of redefining the rules, you should redefine the variable:
:root { --color: green; } div { color: var(--color); } @media screen and (max-width: 768px) { :root { --color: red } }
3 u/winkerback Jul 18 '21 I have never thought of doing it this way
3
I have never thought of doing it this way
13
u/[deleted] Jul 18 '21
I feel like (4) misses the point of cascading style sheets:
Instead of redefining the rules, you should redefine the variable: