Skip to content

Instantly share code, notes, and snippets.

@tdrach
Last active October 16, 2015 17:38
Show Gist options
  • Save tdrach/f9c9fbdb68beaae152bc to your computer and use it in GitHub Desktop.
Save tdrach/f9c9fbdb68beaae152bc to your computer and use it in GitHub Desktop.
Standard SCSS Mixins
@function strip-unit($num) {
@return $num / ($num * 0 + 1);
}
@mixin rem($property, $values...) {
$max: length($values);
$pxValues: '';
$remValues: '';
@for $i from 1 through $max {
$value: strip-unit(nth($values, $i));
$pxValues: #{$pxValues + $value*16}px;
@if $i < $max {
$pxValues: #{$pxValues + " "};
}
}
@for $i from 1 through $max {
$value: strip-unit(nth($values, $i));
$remValues: #{$remValues + $value}rem;
@if $i < $max {
$remValues: #{$remValues + " "};
}
}
#{$property}: $pxValues;
#{$property}: $remValues;
}
// Vendor prefixing
@mixin vp($name, $argument) {
-webkit-#{$name}: #{$argument};
-ms-#{$name}: #{$argument};
-moz-#{$name}: #{$argument};
-o-#{$name}: #{$argument};
#{$name}: #{$argument};
}
// keyframes mixin
@mixin keyframes($name) {
@-webkit-keyframes #{$name} {
@content;
}
@-moz-keyframes #{$name} {
@content;
}
@-ms-keyframes #{$name} {
@content;
}
@keyframes #{$name} {
@content;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment