Skip to content

Instantly share code, notes, and snippets.

@weblancaster
Created October 18, 2012 17:28
Show Gist options
  • Save weblancaster/3913519 to your computer and use it in GitHub Desktop.
Save weblancaster/3913519 to your computer and use it in GitHub Desktop.
Function to transform px to em using SASS
// formula/function to transform px to em.
@function calc-em($target-px, $context) {
@return ($target-px / $context) * 1em;
}
//use like this
selector {
padding-left: calc-em(20px, 16px);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment