Last active
August 29, 2015 14:02
-
-
Save liquorice/0c0a86e14c04694d9f30 to your computer and use it in GitHub Desktop.
SASS keyframes mixin
This file contains hidden or 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
@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