scss之px单位转成vw单位

@charset "UTF-8";

// px单位转成vw单位
@function px2vw($size: 14px, $width: 375px) {
@if (type-of($size) == "number" and unit($size) == "px") {
@return $size * 100vw / $width;
} @else {
@return $size;
}
}

//props-dpr
@mixin props-dpr($props, $values) {
@if length($props) ==1 {
@if length($values) ==1 {
#{$props}: px2vw($values);
} @else {
$valueStr: ();
@each $value in $values {
$valueStr: append($valueStr, px2vw($value));
}
#{$props}: $valueStr;
}
} @else {
@each $prop in $props {
#{$prop}: px2vw(nth($values, index($props, $prop)));
}
}
}

转载于:https://www.cnblogs.com/aisiqi-love/p/11395679.html

你可能感兴趣的:(scss之px单位转成vw单位)