Created
March 27, 2012 15:36
-
-
Save 5509/2217089 to your computer and use it in GitHub Desktop.
Choosing use vendor prefix or not by like hash for Sass
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
$use: | |
-webkit-, true, | |
-moz-, true, | |
-o-, true, | |
-ms-, false; | |
@mixin addPrefix($property, $value, $def: false) { | |
$property: unquote($property); | |
$value: unquote($value); | |
@for $i from 1 through length($use)/2 { | |
$n: $i * 2; | |
$flg: nth($use, $n); | |
$prfx: nth($use, $n - 1); | |
@if $def { | |
$_index: index($def, $prfx); | |
@if $_index { | |
$flg: nth($def, $_index + 1); | |
} | |
} | |
@if $flg { | |
#{$prfx + $property}: $value; | |
} | |
} | |
#{$property}: $value; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
// Usage
// default
@mixin background-size($value) {
@include addPrefix('background-size', $value);
}
// using with default using or not
@mixin box-shadow($value) {
$def:
-webkit-, false,
-ms-, true;
@include addPrefix('box-shadow', $value, $def);
}