Skip to content

Instantly share code, notes, and snippets.

@remainstheday
Created April 11, 2014 18:24
Show Gist options
  • Save remainstheday/10489908 to your computer and use it in GitHub Desktop.
Save remainstheday/10489908 to your computer and use it in GitHub Desktop.
Fun with SASS mixins
@function strip-unit($num) {
@return $num / ($num * 0 + 1);
}
@mixin rem-fallback($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