Skip to content

Instantly share code, notes, and snippets.

@mishelen
Last active September 16, 2015 02:05
Show Gist options
  • Select an option

  • Save mishelen/cf929e3e3ca4938d0fd6 to your computer and use it in GitHub Desktop.

Select an option

Save mishelen/cf929e3e3ca4938d0fd6 to your computer and use it in GitHub Desktop.
Очередная ремопикселе фолбек From http://css-tricks.com/snippets/css/less-mixin-for-rem-font-sizing/
@function strip-unit($num) {
@return $num / ($num * 0 + 1);
}
@mixin rem-fallback($property, $values...) {
$max: length($values);
$pxValues: '';
$remValues: '';
@for $i from 1 through $max {
$value: strip-unit(nth($values, $i));
$pxValues: #{$pxValues + $value*16}px;
@if $i < $max {
$pxValues: #{$pxValues + " "};
}
}
@for $i from 1 through $max {
$value: strip-unit(nth($values, $i));
$remValues: #{$remValues + $value}rem;
@if $i < $max {
$remValues: #{$remValues + " "};
}
}
#{$property}: $pxValues;
#{$property}: $remValues;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment