Created
December 7, 2011 08:18
-
-
Save ijy/1441967 to your computer and use it in GitHub Desktop.
A Compass function to convert pixel font-sizes to em's
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
@function em($target, $context: $base-font-size) { | |
@if $target == 0 { @return 0 } | |
@return $target / $context + 0em; | |
} | |
$base-font-size: 15px; | |
h1 { | |
font-size: em(21px, 15px); // Outputs 1.4em | |
} |
Very useful! Thanks for sharing!
Is there a technical reason why + 0em
is used instead of * 1em
?
Is there a technical reason why
+ 0em
is used instead of* 1em
?
@stevenvachon I believe that's an implicit conversion to ensure the result ends up as em
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks!!!!!
Mobile FIRST