Skip to content

Instantly share code, notes, and snippets.

@echenley
Created March 11, 2015 19:15
Show Gist options
  • Save echenley/fd0feb5018722ba21b4c to your computer and use it in GitHub Desktop.
Save echenley/fd0feb5018722ba21b4c to your computer and use it in GitHub Desktop.
Sass function to convert px to em. Add to _mixins.scss. Optional context parameter.
$base-font-size: 16px; // defined by bootstrap
@function em($target, $context: $base-font-size) {
@if $target == 0 { @return 0 }
@return $target / $context + 0em;
}
// font-size: em(36px);
// => font-size: 2.21875em
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment