erp-el-element/utils/remScale.js

27 lines
1.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// // 获取屏幕宽度
// var screenWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
// console.log(screenWidth);
// // 设置基础字体大小,可以根据需要调整
// var baseFontSize = 16;
// // 根据屏幕宽度计算根元素的字体大小
// var calculatedFontSize = screenWidth / 1920 * baseFontSize;
// // 375是设计稿的宽度可以根据实际情况调整
// // 设置根元素的字体大小
// console.log(calculatedFontSize,"calculatedFontSize");
// (function (doc, win) {
// var docEl = doc.documentElement,
// resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
// recalc = function () {
// var clientWidth = docEl.clientWidth;
// if (!clientWidth) return;
// if(clientWidth>=720){
// docEl.style.fontSize = calculatedFontSize+"px";
// }else{
// docEl.style.fontSize = 16 * (clientWidth / 720) + 'px';
// }
// };
// if (!doc.addEventListener) return;
// win.addEventListener(resizeEvt, recalc, false); //绑定事件
// doc.addEventListener('DOMContentLoaded', recalc, false);
// })(document, window);