// // 获取屏幕宽度 // 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);