Last active
December 30, 2015 18:09
-
-
Save ryanburgess/7865337 to your computer and use it in GitHub Desktop.
REM Unit SASS Mixin auto automatically outputs rem units and pixel value fallback for legacy browsers.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ----------------------------------------- | |
// REM Units with PX fallback | |
// ------------------------------------------- | |
// example: @include rem("margin", 10, 5, 10, 5); | |
// example: @include rem("font-size", 14); | |
@mixin rem($property, $values...) { | |
$n: length($values); | |
$i: 1; | |
$pxlist: (); | |
$remlist: (); | |
@while $i <= $n { | |
$itemVal: (nth($values, $i)); | |
@if $itemVal != "auto"{ | |
$pxlist: append($pxlist, $itemVal + px); | |
$remlist: append($remlist, ($itemVal / 16) + rem); | |
}@else{ | |
$pxlist: append($pxlist, auto); | |
$remlist: append($remlist, auto); | |
} | |
$i: $i + 1; | |
} | |
#{$property}: $pxlist; | |
#{$property}: $remlist; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment