Sass mixin to automate the CSS animation process, including vendor prefixes
//Animation mixin setup
@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};
}
//Usage
// Define animation name, and properties
@include keyframes(fade-out) {
0% { opacity: 1; }
90% { opacity: 0; }
}
// Add animation to element
.element {
width: 100px;
height: 100px;
background: black;
@include animation('fade-out 5s 3');
}