Skip to content

Instantly share code, notes, and snippets.

@ocean90
Created January 2, 2012 20:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ocean90/1552031 to your computer and use it in GitHub Desktop.
Save ocean90/1552031 to your computer and use it in GitHub Desktop.
Convert px to em
// Default font size
$base-font-size: 16px;
// px2em
// Use: font-size: px2em( 12px, 14px );
@function px2em( $target, $context: $base-font-size ) {
@if $target == 0 {
@return 0;
}
@return $target / $context + 0em;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment