@function rem($pixel, $basis: 16) { $negative: false; @if ($pixel < 0) { $negative: true; $pixel: calc($pixel * -1); } $rem: calc($pixel / $basis); @if ($negative) { $rem: calc($rem * -1); } @return $rem + 0rem; }