Skip to content

Instantly share code, notes, and snippets.

@jgillman
Created April 7, 2014 22:50
Show Gist options
  • Select an option

  • Save jgillman/10070705 to your computer and use it in GitHub Desktop.

Select an option

Save jgillman/10070705 to your computer and use it in GitHub Desktop.
Native Sass mixin for CSS3 animation, no Compass needed.
// Choose what browser prefixes you want based on info you find here:
// http://caniuse.com/#feat=css-animation
// Add vendor prefixes to keyframes
@mixin keyframes($animation-name)
@-webkit-keyframes #{$animation-name}
@content
@-moz-keyframes #{$animation-name}
@content
@keyframes #{$animation-name}
@content
// Use syntax like you would with regular CSS animations. No need to limit what
// animation options you can use or what what order to put the arguments in.
//
// Usage: @include animation(my-animation-name 0.6s linear infinite)
@mixin animation ($animation)
-webkit-animation: $animation
-moz-animation: $animation
animation: $animation
// SCSS for the lazy.
// Choose what browser prefixes you want based on info you find here:
// http://caniuse.com/#feat=css-animation
// Add vendor prefixes to keyframes
@mixin keyframes($animation-name) {
@-webkit-keyframes #{$animation-name} {
@content;
}
@-moz-keyframes #{$animation-name} {
@content;
}
@keyframes #{$animation-name} {
@content;
}
}
// Use syntax like you would with regular CSS animations. No need to limit what
// animation options you can use or what what order to put the arguments in.
//
// Usage: @include animation(my-animation-name 0.6s linear infinite)
@mixin animation($animation) {
-webkit-animation: $animation;
-moz-animation: $animation;
animation: $animation;
}
@include keyframes( flash )
0%, 100%
background: #000
50%
background: #fff
.element-to-be-flashed
@include animation(flash 1.6s infinite linear)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment