Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
A Compass function to convert pixel font-sizes to em's
@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
}

yoink just what I needed, thank you

Thanks! I love this.

denoww commented Mar 22, 2013

Thanks!!!!!
Mobile FIRST

D

nelsonr commented Sep 10, 2013

Very useful! Thanks for sharing!

Is there a technical reason why + 0em is used instead of * 1em?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment