Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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