欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

rem

程序员文章站 2022-06-05 16:05:39
/** * @example 1rem=100px */!(function (doc, win) { var docEle = doc.documentElement, resizeEvent = 'orientationchange' in window ? 'orientationchange ......
/**
* @example 1rem=100px
*/
!(function (doc, win) {
var docele = doc.documentelement,
resizeevent = 'orientationchange' in window ? 'orientationchange' : 'resize',
recalc = function () {
var clientwidth = docele.clientwidth;
if (!clientwidth) return;
// 750为设计稿尺寸
docele.style.fontsize = clientwidth >= 750 ? '100px' : 100 * (clientwidth / 750) + 'px'
};
if (!doc.addeventlistener) return;
win.addeventlistener(resizeevent, recalc, false);
doc.addeventlistener('domcontentloaded', recalc, false);
})(document, window);