Skip to content

Instantly share code, notes, and snippets.

@fdaciuk
Forked from arthurgouveia/mixins.scss
Created November 11, 2013 17:53
Show Gist options
  • Save fdaciuk/7417334 to your computer and use it in GitHub Desktop.
Save fdaciuk/7417334 to your computer and use it in GitHub Desktop.
$font-size: 16;
@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}px;
@if $i < $max {
$pxValues: #{$pxValues + " "};
}
}
@for $i from 1 through $max {
$value: strip-unit(nth($values, $i));
$remValues: #{$remValues + ($value/$font-size)}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