@mixin module-width($argus, $mentods){
@if($mentods == 'pc'){
width: ($argus / 1920) * 100vw;
} @else if($mentods == 'H5'){
width: ($argus / 375) * 100vw !important;
}
}
使用:
div{
//pc端
@include module-width(100, 'pc');
//H5端
@include module-width(100, 'H5');
}
@mixin module-height($argus, $mentods){
@if($mentods == 'pc'){
height: ($argus / 980) * 100vh;
} @else if($mentods == 'H5'){
height: ($argus / 767) * 100vh !important;
}
}
使用:
div{
//pc端
@include module-height(100, 'pc');
//H5端
@include module-height(100, 'H5');
}
(这里我的字体是用的vh做单位)
@mixin font-size($argus, $mentods){
@if($mentods == 'pc'){
font-size: ($argus / 980) * 100vh;
} @else if($mentods == 'H5'){
font-size: ($argus / 767) * 100vh !important;
}
}
使用:
div{
//pc端
@include font-size(20, 'pc');
//H5端
@include font-size(20, 'H5');
}
@function adaptation-width($argus, $mentods){
@if($mentods == 'pc'){
@return ($argus / 1920) * 100;
} @else if($mentods == 'H5'){
@return ($argus / 375) * 100;
}
}
@function adaptation-height($argus, $mentods){
@if($mentods == 'pc'){
@return ($argus / 980) * 100;
} @else if($mentods == 'H5'){
@return ($argus / 767) * 100;
}
}
使用:
div{
width: adaptation-width(50vw, 'pc');
height: adaptation-height(50vh, 'pc');
padding: adaptation-height(5vh, 'pc') adaptation-width(5vw, 'pc');
}