_px-to-rem.scss 340 B

123456789101112131415
  1. // Convert pixels to rems
  2. // eg. for a relational value of 12px write rem(12)
  3. // Assumes $em-base is the font-size of <html>
  4. @function rem($pxval) {
  5. @if not unitless($pxval) {
  6. $pxval: strip-units($pxval);
  7. }
  8. $base: $em-base;
  9. @if not unitless($base) {
  10. $base: strip-units($base);
  11. }
  12. @return ($pxval / $base) * 1rem;
  13. }