app.js
require('./index.scss');
//获取屏幕宽度(viewport)
let htmlWidth=document.documentElement.clientWidth || document.body.clientWidth;
//获取html的dom
let htmlDom = document.getElementsByTagName('html')[0];
//设置html的fontSize
htmlDom.style.fontSize=htmlWidth/10+'px';
window.addEventListener('resize',(e)=>{
let htmlWidth=document.documentElement.clientWidth || document.body.clientWidth;
htmlDom.style.fontSize=htmlWidth/10+'px';
});
npm install node-sass
node-sass a.css b.css
@function px2rem($px){
$rem : 37.5px;
@return ( $px / $rem ) + rem
}
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no">