Created
September 22, 2013 18:18
-
-
Save weblancaster/6662409 to your computer and use it in GitHub Desktop.
px to em
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
// It strips the unit of measure and returns it | |
@function strip-unit($num) { | |
@return $num / ($num * 0 + 1); | |
} | |
// Converts "px" to "em" using the ($)em-base | |
@function convert-to-em($value, $base-value: $em-base) { | |
$value: strip-unit($value) / strip-unit($base-value) * 1em; | |
@if ($value == 0em) { $value: 0; } // Turn 0em into 0 | |
@return $value; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment