Created
January 18, 2022 22:52
-
-
Save cecilemuller/10d39a0f56b6867bb87e69fc239cf49a to your computer and use it in GitHub Desktop.
Animated CSS Custom Property
This file contains 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
// Static value by default: | |
// https://caniuse.com/css-variables | |
:root { | |
--example: 0deg; | |
} | |
.myclass { | |
background-image: linear-gradient( var(--example), red, green 50%, blue ); | |
} | |
// Animated value where supported: | |
// https://caniuse.com/mdn-css_at-rules_property | |
@supports (background: paint(a)) { | |
@property --example { | |
syntax: "<angle>"; | |
initial-value: 0deg; | |
inherits: false; | |
} | |
@keyframes spin { | |
0% { | |
--example: 0deg; | |
} | |
100% { | |
--example: 360deg; | |
} | |
} | |
.myclass { | |
animation: spin 2.5s linear infinite; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment