Last active
February 1, 2016 21:04
-
-
Save johnny5th/52bee02773d324bbbeab to your computer and use it in GitHub Desktop.
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
@function em($px, $context-or-rem: strip_unit($base-font-size)) { | |
@if($context-or-rem == true) { | |
@return $px / strip_unit($base-font-size) * 1rem; | |
} @else { | |
@return $px / $context-or-rem * 1em; | |
} | |
} | |
/// Remove the unit of a length | |
/// @param {Number} $number - Number to remove unit from | |
/// @return {Number} - Unitless number | |
@function strip_unit($number) { | |
@if type-of($number) == 'number' and not unitless($number) { | |
@return $number / ($number * 0 + 1); | |
} | |
@return $number; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment