qd-changjing/src/utils/rem.js

27 lines
942 B
JavaScript
Raw Normal View History

2022-07-05 16:56:29 +08:00
/*
* @Author: hisense.wuhongjian
* @Date: 2021-06-15 18:50:17
* @LastEditors: hisense.wuhongjian
* @LastEditTime: 2021-08-23 17:09:20
* @Description: 告诉大家这是什么
*/
(function (doc, win) {
var docEl = doc.documentElement
var resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize'
var recalc = function () {
var clientWidth = docEl.clientWidth;
var clientHeight = docEl.clientHeight;
if (!clientWidth) return
/* if ((clientWidth / 19.2) >= 80) {
docEl.style.fontSize = (clientWidth / 19.2) + 'px'
} else {
docEl.style.fontSize = 80 + 'px'
} */
clientWidth > 1920 ? clientWidth = 1920 : clientWidth;
docEl.style.fontSize = (clientWidth / 19.2) + 'px';
}
if (!doc.addEventListener) return
recalc()
win.addEventListener(resizeEvt, recalc, false)
doc.addEventListener('DOMContentLoaded', recalc, false)
})(document, window)