_px-to-em.scss 370 B

12345678910111213
  1. // Convert pixels to ems
  2. // eg. for a relational value of 12px write em(12) when the parent is 16px
  3. // if the parent is another value say 24px write em(12, 24)
  4. @function em($pxval, $base: $em-base) {
  5. @if not unitless($pxval) {
  6. $pxval: strip-units($pxval);
  7. }
  8. @if not unitless($base) {
  9. $base: strip-units($base);
  10. }
  11. @return ($pxval / $base) * 1em;
  12. }