Skip to content

Instantly share code, notes, and snippets.

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 matheusmurta/3ff6167efbd62a27cdd6085a6c465bd2 to your computer and use it in GitHub Desktop.
Save matheusmurta/3ff6167efbd62a27cdd6085a6c465bd2 to your computer and use it in GitHub Desktop.
A Keyframes Mixin (Sass only)
@-webkit-keyframes bgcolor { 0% { background-color: #ffccf2; }
50% { background-color: #ccffcc; }
100% { background-color: #ccffff; } }
@-moz-keyframes bgcolor { 0% { background-color: #ffccf2; }
50% { background-color: #ccffcc; }
100% { background-color: #ccffff; } }
@-ms-keyframes bgcolor { 0% { background-color: #ffccf2; }
50% { background-color: #ccffcc; }
100% { background-color: #ccffff; } }
@keyframes bgcolor { 0% { background-color: #ffccf2; }
50% { background-color: #ccffcc; }
100% { background-color: #ccffff; } }
/*
Syntax error: Invalid CSS after "...bkit-keyframes ": expected "}", was "#{$name} {"
// keyframes mixin
=keyframes($name)
@-webkit-keyframes #{$name}
@content
@-moz-keyframes #{$name}
@content
@-ms-keyframes #{$name}
@content
@keyframes #{$name}
@content
// use of keyframes mixin
+keyframes(bgcolor)
0%
background-color: #ffccf2
50%
background-color: #ccffcc
100%
background-color: #ccffff
// keyframes mixin
@mixin keyframes($name) {
@-webkit-keyframes #{$name} {
@content;
}
@-moz-keyframes #{$name} {
@content;
}
@-ms-keyframes #{$name} {
@content;
}
@keyframes #{$name} {
@content;
}
}
// use of keyframes mixin
@include keyframes(bgcolor) {
0% {
background-color: #ffccf2;
}
50% {
background-color: #ccffcc;
}
100% {
background-color: #ccffff;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment