Skip to content

Instantly share code, notes, and snippets.

@liquorice
Last active August 29, 2015 14:02
Show Gist options
  • Save liquorice/0c0a86e14c04694d9f30 to your computer and use it in GitHub Desktop.
Save liquorice/0c0a86e14c04694d9f30 to your computer and use it in GitHub Desktop.
SASS keyframes mixin
@mixin animation($options...) {
$random: random(9999);
$animation_name: "animation_#{$random}";
-webkit-animation: $animation_name $options;
-moz-animation: $animation_name $options;
-ms-animation: $animation_name $options;
animation: $animation_name $options;
@at-root {
@-webkit-keyframes $animation_name {
@content;
}
@-moz-keyframes $animation_name {
@content;
}
@-ms-keyframes $animation_name {
@content;
}
@keyframes $animation_name {
@content;
}
}
}
.example {
@include animation() {
0% { top: 0; }
50% { top: 50px; }
100% { top: 100px; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment