Skip to content

Instantly share code, notes, and snippets.

@yairEO
Created February 5, 2022 20:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yairEO/bd8d33822e08964b4a5e29c76cd70063 to your computer and use it in GitHub Desktop.
Save yairEO/bd8d33822e08964b4a5e29c76cd70063 to your computer and use it in GitHub Desktop.
Toggle CSS block with a single variable
// https://css-tricks.com/css-switch-case-conditions
// simplified version of my method:
.foo {
--feature: 1; // 1 is "on", 0 is "off"
animation: foo_styles 1s calc(-1s * (var(--feature) - 1)) paused;
@keyframes foo_styles {
0% {
background: red;
box-shadow: 0 0 10px;
color: white;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment