根据屏幕尺寸计算rem

!(function (doc, win) {
    var docEle = doc.documentElement,
        evt = "onorientationchange" in window ? "orientationchange" : "resize",
        fn = function () {
            var width = docEle.clientWidth;
            // width && (docEle.style.fontSize = 20 * (width / 375) + "px");
            width && (docEle.style.fontSize = 10*width / 75 + "px");
        };

    win.addEventListener(evt, fn, false);
    doc.addEventListener("DOMContentLoaded", fn, false);

}(document, window));

  

posted @ 2018-02-23 15:01  橙云生  阅读(659)  评论(0编辑  收藏  举报