Skip to content

Instantly share code, notes, and snippets.

@robert-moore
Created November 8, 2014 15:09
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 robert-moore/1ccbaf662d6343c8be29 to your computer and use it in GitHub Desktop.
Save robert-moore/1ccbaf662d6343c8be29 to your computer and use it in GitHub Desktop.
A mixin for simple keyframe animations with SASS
@mixin keyframes($animation-name) {
@-webkit-keyframes $animation-name {
@content;
}
@-moz-keyframes $animation-name {
@content;
}
@-ms-keyframes $animation-name {
@content;
}
@-o-keyframes $animation-name {
@content;
}
@keyframes $animation-name {
@content;
}
}
@mixin animation($str) {
-webkit-animation: #{$str};
-moz-animation: #{$str};
-ms-animation: #{$str};
-o-animation: #{$str};
animation: #{$str};
}
/* Use */
@include keyframes(slide-down) {
0% { opacity: 1; }
90% { opacity: 0; }
}
.element {
width: 100px;
height: 100px;
background: black;
@include animation('slide-down 5s 3');
}
/* from http://zerosixthree.se/8-sass-mixins-you-must-have-in-your-toolbox/ */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment