Skip to content

Instantly share code, notes, and snippets.

@welly
Created August 5, 2013 13:55
Show Gist options
  • Save welly/6156083 to your computer and use it in GitHub Desktop.
Save welly/6156083 to your computer and use it in GitHub Desktop.
PX to EM conversion functions
// Functions for px to em conversions
// ------------------------------------------------------------
@function emify($target, $context) {
@if $target == 0 { @return 0 }
@return $target / $context + 0em;
}
// Make px to ems using base-font-size
// echo as: font-size: em-font(#px);
@function em-font($target, $context: $base-font-size) {
@return emify($target, $context);
}
// Make px to ems using base-line-height
// echo as: font-size: em-base(#px);
@function em-base($target, $context: $base-line-height) {
@return emify($target, $context);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment