Last active
March 15, 2016 17:10
-
-
Save lepittenger/2a5848803d865afe4420 to your computer and use it in GitHub Desktop.
calculate ems based on pixel value
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
/* calculate ems based on pixel value | |
use it like em(16px) or em(16) */ | |
$browser-context: 16; | |
@function em($pixels, $context: $browser-context) { | |
@if (unitless($pixels)) { | |
$pixels: $pixels * 1px; | |
} | |
@if (unitless($context)) { | |
$context: $context * 1px; | |
} | |
@return $pixels / $context * 1em; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment