Instantly share code, notes, and snippets.

Embed
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
}
@LimeBlast

This comment has been minimized.

LimeBlast commented Mar 2, 2013

yoink just what I needed, thank you

@emilchristensen

This comment has been minimized.

emilchristensen commented Mar 5, 2013

Thanks! I love this.

@denoww

This comment has been minimized.

denoww commented Mar 22, 2013

Thanks!!!!!
Mobile FIRST

D

@nelsonr

This comment has been minimized.

nelsonr commented Sep 10, 2013

Very useful! Thanks for sharing!

@stevenvachon

This comment has been minimized.

stevenvachon commented Aug 22, 2016

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