根据当前设备的宽度,动态计算出rem的换算比例,实现页面中元素的等比缩放
~function anonymous(window){
//根据当前设备的宽度,动态计算出rem的换算比例,实现页面中元素的等比缩放
let computedREM = function computedREM(){
let winW = document.documentElement.clientWidth,
desW = 640;
if(winW>640){
document.documentElement.style.fontSize = '100px';
return;
}
document.documentElement.style.fontSize = winW/desW * 100 +'px';
};
computedEEM();
window.addEventListener('resize',computedREM);
}(window);