html 使用rem开发

 window.onload = function () {
            var ohtml = document.getElementsByTagName("html")[0];
            var widthMax = document.documentElement.clientWidth;
            if (widthMax > 750) {
                ohtml.style.fontSize = '100px';
            }
            else {
                ohtml.style.fontSize = (widthMax / 750) * 100 + 'px';
            }
        }

html 默认字体 100px

    $(function () { loadlogininfo(); });

    //html root的字体计算应该放在最前面,这样计算就不会有误差了/
    //2016.3.23 wjq update 之所以要加个判断返回一个20.5,是因为当用户在谷歌等浏览器直接输入手机端网站网址时,如果用户设置模块自定义样式的高度比较小,由于这时候的clientWidth为1920px,及返回的_htmlFontSize为40,这时候就会使模块太小,展示不完全,因此先取一个较为准确的值去展示。Mobi.resetHtmlFontSize()顺便也加了
    var _htmlFontSize = (function () {
        var clientWidth = document.documentElement ? document.documentElement.clientWidth : document.body.clientWidth;
        //if(clientWidth > 768) clientWidth = 768;
        if (clientWidth > 768 && clientWidth < 1280) {
            clientWidth = 768;
        } else if (clientWidth >= 1280) {
            clientWidth = 512;
        }
        document.documentElement.style.fontSize = clientWidth * 1 / 16 + "px";
        return clientWidth * 1 / 16;
    })();
原文地址:https://www.cnblogs.com/prolion/p/9223457.html