Skip to content

Instantly share code, notes, and snippets.

@SteAllan
Created January 21, 2014 08:22
Show Gist options
  • Save SteAllan/8536220 to your computer and use it in GitHub Desktop.
Save SteAllan/8536220 to your computer and use it in GitHub Desktop.
A Sass function to convert px values into rems, based on the px to em function in Bourbon (http://bourbon.io/docs/#px-to-em)
// Convert a px value into a rem value.
// Supply the rem value to the primary style sheet and the px fallback to the ltie9 style sheet.
@function rem($pxval) {
$val: strip-unit($pxval);
$base: strip-unit($browser-default-font-size);
@if ($ltie9 == true) {
@return $val * 1px;
}
@else {
@return ($val / $base) * 1rem;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment