H5 px rem 单位换算

来源:互联网 发布:遗传算法与蚁群算法 编辑:程序博客网 时间:2024/06/11 15:45
;(function(w) {     var _config = w.comConfig,        comFuc = {        init: function(){            var self = this;            self.configRem();                    },        configRem: function(){            if(_config && !_config.hideRem){                  fixRem();                window.addEventListener('resize', fixRem, false);                       }        },        fixRem: function(){            var windowWidth =  document.documentElement.clientWidth || window.innerWidth || document.body.clientWidth;            var rootSize = 28 * ( windowWidth / 375);            var htmlNode = document.getElementsByTagName("html")[0];            htmlNode.style.fontSize = rootSize+'px';        }    };    //通过window width 修改html font-size    function fixRem(){        var windowWidth =  document.documentElement.clientWidth || window.innerWidth || document.body.clientWidth;        var rootSize = 28 * ( windowWidth / 375);        var htmlNode = document.getElementsByTagName("html")[0];        htmlNode.style.fontSize = rootSize+'px';    }    // fixRem();    comFuc.init();})(window);
原创粉丝点击