Created
May 7, 2020 21:40
-
-
Save richleach/211791a58e0c61571e9e911f66d70269 to your computer and use it in GitHub Desktop.
CSS: Finally the standard CSS implementation is starting to catch up with LESS/SCSS and gives us variables to use in CSS code
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
// define all CSS variables in the root block | |
:root { | |
--main-color: blue; | |
} | |
.hover-text { | |
transition: all 0.5s; | |
} | |
//apply CSS variables using var() method and the variable name | |
.hover-text:hover { | |
color: var(--main-color); | |
font-size: 20px; | |
} | |
.box { | |
position: fixed; | |
width: 50px; | |
height: 50px; | |
background: red; | |
border: 1px solid black; | |
animation: size-down ease-out 0.5s infinite alternate both; | |
} | |
@keyframes size-down { | |
//apply CSS variables using var() method and the variable name | |
100% {transform: scale(0.3, 0.3); background: var(--main-color);} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment