Created
April 21, 2017 09:53
-
-
Save taxigy/c4e2a165c5a5ab8df996e2c700d92c33 to your computer and use it in GitHub Desktop.
Variables in CSS styles
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ONE: nested media query and calc */ | |
:root { | |
--value: 30px; | |
} | |
.element { | |
border-radius: var(--value); | |
@media (min-width: 768px) { | |
border-radius: calc(var(--value) * 2); | |
} | |
} | |
/* TWO: redefining variable against media query separately from style declarations */ | |
:root { | |
--value: 30px; | |
} | |
@media (min-width: 768px) { | |
--value: 60px; | |
} | |
.element { | |
border-radius: var(--value); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In Pure CSS second example doesn't work but after small modification the following works fine.