Created
August 5, 2013 13:55
-
-
Save welly/6156083 to your computer and use it in GitHub Desktop.
PX to EM conversion functions
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
// Functions for px to em conversions | |
// ------------------------------------------------------------ | |
@function emify($target, $context) { | |
@if $target == 0 { @return 0 } | |
@return $target / $context + 0em; | |
} | |
// Make px to ems using base-font-size | |
// echo as: font-size: em-font(#px); | |
@function em-font($target, $context: $base-font-size) { | |
@return emify($target, $context); | |
} | |
// Make px to ems using base-line-height | |
// echo as: font-size: em-base(#px); | |
@function em-base($target, $context: $base-line-height) { | |
@return emify($target, $context); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment