(function () {
// 设计稿尺寸为750
var baseWidth = 750;
var set = function () {
var baseFontSize = 100;
// 获取当前屏幕的宽度;
var clientWidth = document.documentElement.clientWidth || document.innerWidth;
if (clientWidth != baseWidth) {
baseFontSize = clientWidth / baseWidth * baseFontSize;
}
document.querySelector("html").style.fontSize = baseFontSize + "px";
}
set();
// 监听屏幕尺寸变化
window.addEventListener("resize", set);
// window.οnresize=set
}())
移动端rem适配
最新推荐文章于 2024-08-04 16:33:59 发布