Skip to content

Instantly share code, notes, and snippets.

@cecilemuller
Created January 18, 2022 22:52
Show Gist options
  • Save cecilemuller/10d39a0f56b6867bb87e69fc239cf49a to your computer and use it in GitHub Desktop.
Save cecilemuller/10d39a0f56b6867bb87e69fc239cf49a to your computer and use it in GitHub Desktop.
Animated CSS Custom Property
// 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