Skip to content

Instantly share code, notes, and snippets.

@neoascetic
Last active August 29, 2015 14:07
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 neoascetic/5d7aadafc826372c874f to your computer and use it in GitHub Desktop.
Save neoascetic/5d7aadafc826372c874f to your computer and use it in GitHub Desktop.
[less] vendor prefixer mixin
// code from https://github.com/neoascetic/compless
// >> .prefix(box-shadow, 5px);
// -webkit-box-shadow: 5px;
// -moz-box-shadow: 5px;
// -ms-box-shadow: 5px;
// -o-box-shadow: 5px;
// box-shadow: 5px;
//
// >> .prefix(box-shadow, 5px, webkit ms);
// -webkit-box-shadow: 5px;
// -ms-box-shadow: 5px;
// box-shadow: 5px;
@prefixes: webkit moz ms o;
.prefix(@property, @value) {
.prefix(@property, @value, @prefixes);
}
.prefix(@property, @value, @prefixes) {
.prefix(@property, @value, @prefixes, 1);
@{property}: @value;
}
.prefix(@property, @value, @prefixes, @index) when (@index > 0) and (length(@prefixes) >= @index) {
@prefix: extract(@prefixes, @index);
-@{prefix}-@{property}: @value;
.prefix(@property, @value, @prefixes, @index + 1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment