core/skin/virtual-nt.ru/sass/directional/_rem.scss

37 lines
823 B
SCSS
Raw Normal View History

2023-02-25 22:58:56 +05:00
//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] */
}