Sha256: 01d844056723c5636c2316c30f44d09d4b360e41015cb0c8476d9a2077c5ed89

Contents?: true

Size: 908 Bytes

Versions: 3

Compression:

Stored size: 908 Bytes

Contents

// My modified version of Karl Merkli's rem mixin from http://css-tricks.com/snippets/css/less-mixin-for-rem-font-sizing/.
// Pass in a property name and the target pixel values and the mixin will spit out the pixel fallback version and the rem version.

@mixin rem-fallback($property, $values...) {
  $max: length($values);
  $pxValues: '';
  $remValues: '';

  @for $i from 1 through $max {
    $value: strip-unit(nth($values, $i));

    // If the value is '0' don't output the unit.
    @if $value == 0 {
      $pxValues: #{$pxValues + $value*1};
      $remValues: #{$remValues + $value/16};
    }

    // Else do output the unit.
    @else {
      $pxValues: #{$pxValues + $value*1}px;
      $remValues: #{$remValues + $value/16}rem;
    }

    @if $i < $max {
      $pxValues: #{$pxValues + " "};
      $remValues: #{$remValues + " "};
    }
  }

  #{$property}: $pxValues;
  #{$property}: $remValues;
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
minable-0.1.3 app/assets/stylesheets/minable/common/helpers/mixins/_rem-fallback.scss
minable-0.1.2 app/assets/stylesheets/minable/common/helpers/mixins/_rem-fallback.scss
minable-0.1.1 app/assets/stylesheets/minable/helpers/mixins/_rem-fallback.scss