37 lines
823 B
SCSS
37 lines
823 B
SCSS
|
//The ultimate PX/REM mixin
|
||
|
//http://hugogiraudel.com/2013/03/18/ultimate-rem-mixin/
|
||
|
|
||
|
@function parseInt($n) { /* [2] */
|
||
|
@return $n / ($n * 0 + 1);
|
||
|
}
|
||
|
|
||
|
@mixin rem($property, $values) {
|
||
|
$px : ();
|
||
|
$rem: ();
|
||
|
|
||
|
@each $value in $values { /* [4] */
|
||
|
|
||
|
@if $value == 0 or $value == auto { /* [5] */
|
||
|
$px : append($px , $value);
|
||
|
$rem: append($rem, $value);
|
||
|
}
|
||
|
|
||
|
@else {
|
||
|
$unit: unit($value); /* [6] */
|
||
|
$val: parseInt($value); /* [6] */
|
||
|
|
||
|
@if $unit == "px" { /* [7] */
|
||
|
$px : append($px, $value);
|
||
|
$rem: append($rem, ($val / 10 * 1rem));
|
||
|
}
|
||
|
|
||
|
@if $unit == "rem" { /* [7] */
|
||
|
$px : append($px, ($val * 10 * 1px));
|
||
|
$rem: append($rem, $value);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#{$property}: $px; /* [8] */
|
||
|
#{$property}: $rem; /* [8] */
|
||
|
}
|