Created
October 10, 2014 10:12
-
-
Save mattjburrows/d02d963bc2f8c9fd04c1 to your computer and use it in GitHub Desktop.
Rem mixin
This file contains hidden or 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
@mixin rem($property, $px, $base: 16px) { | |
// Convert the baseline into rems | |
$rem: $base / 1rem; | |
// Print the first line in pixel values | |
#{$property}: $px; | |
// If there is only one (numeric) value, return the property/value line for it. | |
@if type-of($px) == "number" { | |
#{$property}: $px / $rem; | |
} | |
@else { | |
// Create an empty list that we can dump values into | |
$rem-values: unquote(""); | |
@each $value in $px { | |
// If the value is zero, return 0 | |
@if $value == 0 { | |
$rem-values: append($rem-values, $value); | |
} | |
@else { | |
$rem-values: append($rem-values, $value / $rem); | |
} | |
} | |
// Return the property and its list of converted values | |
#{$property}: $rem-values; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment