megclaypool
6/28/2018 - 2:04 PM

Messing around with a px-to-rem function to include in a fluid typography mixin

Messing around with a px-to-rem function to include in a fluid typography mixin

@function px-to-rem($values) {
  $rem: ();

  @each $value in $values {

    @if $value == 0 or $value == auto {
      $rem: append($rem, $value);
    } @else {
      $unit: unit($value);
      $val: parseInt($value);

      @if $unit == 'px' {
        $rem: append($rem,  ($val / 10 + rem));
      }
    }
  }
  return $rem;
}