Skip to content

Instantly share code, notes, and snippets.

@richleach
Created May 7, 2020 21:40
Show Gist options
  • Save richleach/211791a58e0c61571e9e911f66d70269 to your computer and use it in GitHub Desktop.
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
// 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