Created
May 16, 2013 18:02
-
-
Save EdPoole/5593712 to your computer and use it in GitHub Desktop.
Converts pixel values to rem values with pixel fallbacks.
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
$baseline_px: 16px; | |
@mixin rem($property, $px_values) { | |
$baseline_rem: ($baseline_px / 1rem); | |
#{$property}: $px_values; | |
@if type-of($px_values) == 'number' { | |
#{$property}: $px_values / $baseline_rem; | |
} @else { | |
$rem_values: (); | |
@each $value in $px_values { | |
@if $value == 0 { | |
$rem_values: append($rem_values, $value); | |
} @else { | |
$rem_values: append($rem_values, ($value / $baseline_rem) ); | |
} | |
} | |
#{$property}: $rem_values; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment