Skip to content

Instantly share code, notes, and snippets.

@nicooprat
Created April 24, 2014 22:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicooprat/11272098 to your computer and use it in GitHub Desktop.
Save nicooprat/11272098 to your computer and use it in GitHub Desktop.
Vendor prefix mixin for LESS
/* It should output something like this... Easy ! */
.test {
animation: pulse 0.5s 1 both;
-ms-animation: pulse 0.5s 1 both;
-moz-animation: pulse 0.5s 1 both;
-webkit-animation: pulse 0.5s 1 both;
-o-animation: pulse 0.5s 1 both;
transition: all 0.25s;
-ms-transition: all 0.25s;
-moz-transition: all 0.25s;
-webkit-transition: all 0.25s;
-o-transition: all 0.25s;
transform: scale(1.5);
-ms-transform: scale(1.5);
-moz-transform: scale(1.5);
-webkit-transform: scale(1.5);
-o-transform: scale(1.5);
}
// --------------
// Needs LESS compiler >= 1.6.0
// Docs : http://lesscss.org/features/#variables-feature-properties
// --------------
// 1. Define the mixin
.vendor-prefix(@prop,@val) {
@{prop}: @val;
-ms-@{prop}: @val;
-moz-@{prop}: @val;
-webkit-@{prop}: @val;
-o-@{prop}: @val;
}
// 2. Use it
.test {
.vendor-prefix( animation, pulse .5s 1 both );
.vendor-prefix( transition, all .25s );
.vendor-prefix( transform, scale(1.5) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment