SASS: REM Fallback Mixin
/*
* Rem Fallback Mixin
* See @ http://css-tricks.com/snippets/css/less-mixin-for-rem-font-sizing/
*/
@function strip-unit($num) {
@return $num / ($num * 0 + 1);
}
@mixin remFallback($property, $values...) {
$max: length($values);
$pxValues: '';
$remValues: '';
@for $i from 1 through $max {
$value: strip-unit(nth($values, $i));
$pxValues: #{$pxValues + $value*10}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;
}