页面在移动端设备上进行等比缩放,设计稿按 750

//等比缩放
!(function(doc, win) {
    var timer,
        docEle = doc.documentElement,
        evt = "onorientationchange" in window ? "orientationchange" : "resize",
        setFontSize = function() {
            var width = docEle.getBoundingClientRect().width;
            width && (docEle.style.fontSize = 20 * (width / 320) + "px");
        };

    win.addEventListener(evt, function() {
        clearTimeout(timer);
        timer = setTimeout(setFontSize, 1000);
    }, false);
    setFontSize();
}(document, window));

可以把这段代码单独存放到一个js文件里,在html中引入,页面样式 使用 rem 为单位,

在 px2rem 插件中 设置 

46.875; // 根元素字体大小(设备宽度/320 * 20)
var remUnit = 46.875; // 根元素字体大小(设备宽度/320 * 20)
原文地址:https://www.cnblogs.com/suntao666/p/9706749.html