Skip to content

Instantly share code, notes, and snippets.

@yarkovaleksei
Forked from Integralist/1. Example.scss
Created May 18, 2018 09:55
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 yarkovaleksei/2113b8bb3dbd3a40abe33921159bf1c9 to your computer and use it in GitHub Desktop.
Save yarkovaleksei/2113b8bb3dbd3a40abe33921159bf1c9 to your computer and use it in GitHub Desktop.
Sass Mixin for CSS3 Animations
@include keyframe(fadeout) {
0% {
opacity: 1;
}
100% {
opacity: 0;
}
}
@include keyframe(changecolour) {
0% {
color: #000;
}
100% {
color: #FFF;
}
}
@mixin keyframe ($animation_name) {
@-webkit-keyframes $animation_name {
@content;
}
@-moz-keyframes $animation_name {
@content;
}
@-o-keyframes $animation_name {
@content;
}
@keyframes $animation_name {
@content;
}
}
/*
Example usage:
@include animation(10s, 5s, changecolour)
*/
@mixin animation ($delay, $duration, $animation) {
-webkit-animation-delay: $delay;
-webkit-animation-duration: $duration;
-webkit-animation-name: $animation;
-webkit-animation-fill-mode: forwards; /* this prevents the animation from restarting! */
-moz-animation-delay: $delay;
-moz-animation-duration: $duration;
-moz-animation-name: $animation;
-moz-animation-fill-mode: forwards; /* this prevents the animation from restarting! */
-o-animation-delay: $delay;
-o-animation-duration: $duration;
-o-animation-name: $animation;
-o-animation-fill-mode: forwards; /* this prevents the animation from restarting! */
animation-delay: $delay;
animation-duration: $duration;
animation-name: $animation;
animation-fill-mode: forwards; /* this prevents the animation from restarting! */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment