Skip to content

Instantly share code, notes, and snippets.

@anthonyshort
Created August 29, 2011 12:31
Show Gist options
  • Star 22 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save anthonyshort/1178298 to your computer and use it in GitHub Desktop.
Save anthonyshort/1178298 to your computer and use it in GitHub Desktop.
Prefixing with Sass
@mixin border-radius($radius, $prefixes: -moz -webkit -o) {
@each $prefix in $prefixes {
#{$prefix}-border-radius:$radius;
}
border-radius:$radius;
}
#id {
@include border-radius(5px, -moz -webkit);
}
// Gives you
#id {
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
}
// Or make it even more generic
@mixin prefix($property, $value, $prefixes) {
@each $prefix in $prefixes {
#{$prefix}-#{$property}:$value;
}
#{$property}:$value;
}
@mixin border-radius($radius, $prefixes: -moz -webkit -o) {
@include prefix(border-radius,$radius,$prefixes);
}
@RaphaelDDL
Copy link

Nice prefix'ing @mixin!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment