Skip to content

Instantly share code, notes, and snippets.

@leongaban
Created March 7, 2014 22:40
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 leongaban/9421693 to your computer and use it in GitHub Desktop.
Save leongaban/9421693 to your computer and use it in GitHub Desktop.
SASS mixin for Pixels to EM
// ----
// Sass (v3.3.0.rc.5)
// Compass (v1.0.0.alpha.18)
// ----
/* PIXELS to EM */
// eg. for a relational value of 12px write em(12) when the parent is 16px
// if the parent is another value say 24px write em(12, 24)
// @include em(12);
@function em($pxval, $base: $em-base) {
@if not unitless($pxval) {
$pxval: strip-units($pxval);
}
@if not unitless($base) {
$base: strip-units($base);
}
@return ($pxval / $base) * 1em;
}
// widget table headers
section header h1 {
font-family: LatoRegular;
font-size: em(18);
}
Undefined variable: "$em-base".
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment