Skip to content

Instantly share code, notes, and snippets.

Created November 11, 2014 21:19
Show Gist options
  • Save anonymous/ace84c8e4842c4850377 to your computer and use it in GitHub Desktop.
Save anonymous/ace84c8e4842c4850377 to your computer and use it in GitHub Desktop.
Rem Mixin
@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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment