Created
October 16, 2013 17:58
-
-
Save onishiweb/7012088 to your computer and use it in GitHub Desktop.
Rem Sass mixin (originally by @BPScott)
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
// Rems with pixel fallback for any property | |
// @author @BPScott (https://github.com/BPScott/bpscott.github.io/blob/develop/source/stylesheets/vendor/_rem.scss) | |
@mixin rem($property, $px-values, $baseline-px: $base-font-size) { | |
// Convert the baseline into rems | |
$baseline-rem: $baseline-px / 1rem; | |
// Create an empty list that we can dump values into | |
$rem-values: (); | |
@each $value in $px-values { | |
// If the value is zero, return 0 | |
$rem-values: append($rem-values, if($value == 0, $value, $value / $baseline-rem)); | |
} | |
// Output the property's px and rem values | |
#{$property}: $px-values; | |
#{$property}: $rem-values; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment