Last active
August 29, 2015 14:15
-
-
Save kostasx/c3aeaa81013f4b03e069 to your computer and use it in GitHub Desktop.
CSS3 Animation & Keyframes LESS Mixins
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
/* #1 A SIMPLE WAY */ | |
/* SOURCE: http://radiatingstar.com/css-keyframes-animations-with-less */ | |
@-webkit-keyframes some-animation {.mixi-frames;} | |
@-moz-keyframes some-animation {.mixi-frames;} | |
@-ms-keyframes some-animation {.mixi-frames;} | |
@-o-keyframes some-animation {.mixi-frames;} | |
@keyframes some-animation {.mixi-frames;} | |
.mixi-frames () { | |
from {width: 254px;} | |
to {width: 512px;} | |
} | |
/* RESULTING CSS: */ | |
@-webkit-keyframes some-animation { | |
from {width: 254px;} | |
to {width: 512px;} | |
} | |
@-moz-keyframes some-animation { | |
from {width: 254px;} | |
to {width: 512px;} | |
} | |
@-ms-keyframes some-animation { | |
from {width: 254px;} | |
to {width: 512px;} | |
} | |
@-o-keyframes some-animation { | |
from {width: 254px;} | |
to {width: 512px;} | |
} | |
@keyframes some-animation { | |
from {width: 254px;} | |
to {width: 512px;} | |
} | |
/* #2 A BETTER WAY */ | |
/* SOURCE: http://codepen.io/zvuc/pen/xvoys/ */ | |
.keyframes(@name; @arguments) { | |
@-moz-keyframes @name { @arguments(); } | |
@-webkit-keyframes @name { @arguments(); } | |
@keyframes @name { @arguments(); } | |
} | |
.animation(@arguments) { | |
-webkit-animation: @arguments; | |
-moz-animation: @arguments; | |
animation: @arguments; | |
} | |
/* EXAMPLE USAGE: */ | |
.container { | |
.keyframes(fade-in;{ | |
0% { opacity: 0; } | |
100% { opacity: 1; } | |
}); | |
.animation(fade-in 0.2s linear infinite alternate) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment