移动端pic转rem

1.

window.onload = function () {
getRem( 750, 100 )
};
window.onresize = function () {
getRem( 750, 100 )
};
function getRem( pwidth, prem ) {
var html = document.getElementsByTagName( "html" )[0];
var oWidth = document.body.clientWidth || document.documentElement.clientWidth;
html.style.fontSize = oWidth / pwidth * prem + "px";
}

750屏幕宽,7.5rem相当于750px, 设计稿同比缩放
原文地址:https://www.cnblogs.com/miaSlady/p/8690116.html