!function(win,doc){
win.onload = function(){
const PXSTANDARD = 375, REMUNIT = 100;
var ST = null, winWidth = 0;
win.addEventListener("resize",function(){
clearTimeout(ST)
ST = setTimeout(function(){
setBodyFontSize();
},60);
})
function setBodyFontSize(){
winWidth = win.innerWidth;
doc.documentElement.style.fontSize = winWidth/PXSTANDARD*REMUNIT + 'px';
}
setBodyFontSize();
}
}(window,document)

本文介绍了一种使用JavaScript实现的自适应网页布局方法,通过监听窗口大小变化,动态调整根元素的字体大小,确保不同设备上的一致显示效果。
986

被折叠的 条评论
为什么被折叠?



