码迷,mamicode.com
首页 > 其他好文 > 详细

rem_750

时间:2017-09-20 19:39:51      阅读:120      评论:0      收藏:0      [点我收藏+]

标签:document   class   ret   cti   res   window   log   hang   eve   

/* fix the code flash the page  */
var globalWidth = document.documentElement.clientWidth;//window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
var radixNO = 100/750*globalWidth;
document.documentElement.style.fontSize = radixNO + ‘px‘;
/* fit document fit the screen, get the radix */
(function (doc, win) {
    var docEl = doc.documentElement,
            resizeEvt = ‘orientationchange‘ in window ? ‘orientationchange‘ : ‘resize‘,
            recalc = function () {
                var globalWidth = window.innerWidth;// for judge the screen ??
                var clientWidth = docEl.clientWidth;
                if (!clientWidth) return;
                docEl.style.fontSize = 100 * (clientWidth / 750) + ‘px‘;
            };
    if (!doc.addEventListener) return;
    win.addEventListener(resizeEvt, recalc, false);
    doc.addEventListener(‘DOMContentLoaded‘, recalc, false);
})(document, window);

 

rem_750

标签:document   class   ret   cti   res   window   log   hang   eve   

原文地址:http://www.cnblogs.com/lengyue0030/p/7562862.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!