mirror of
https://gitee.com/lab1024/smart-admin.git
synced 2025-11-21 18:06:52 +08:00
missing file
This commit is contained in:
20
rc-busness/config/rem.js
Normal file
20
rc-busness/config/rem.js
Normal file
@@ -0,0 +1,20 @@
|
||||
// 隔离作用域,避免全局变量的污染
|
||||
!(function(){
|
||||
function setHtmlFontSize(){
|
||||
// 1.获取手机屏幕宽度
|
||||
var w = document.documentElement.getBoundingClientRect().width; //如果用window.innerwidth的话,改变窗口大小,不能够及时获取窗口大小
|
||||
// console.log(w);
|
||||
// 2.根据屏幕宽度计算html font-size大小, 7.5指的是设计稿的宽度为750,如果在公司中设计稿的尺寸为720,那么应该除以7.2
|
||||
var f = w/40;
|
||||
// 3.设置html 的font-szie
|
||||
document.documentElement.style.fontSize=f+"px";
|
||||
}
|
||||
setHtmlFontSize();
|
||||
window.addEventListener("resize",function(){
|
||||
// setTimeout 是为了解决在苹果手机上的闪屏情况
|
||||
setTimeout(function(){
|
||||
setHtmlFontSize();
|
||||
},300)
|
||||
|
||||
})
|
||||
})();
|
||||
Reference in New Issue
Block a user