浏览代码

样式优化

username 1 年之前
父节点
当前提交
62ed9fd3cb
共有 2 个文件被更改,包括 16 次插入11 次删除
  1. 5 0
      src/app/globals.css
  2. 11 11
      src/utils/index.ts

+ 5 - 0
src/app/globals.css

@@ -7,9 +7,14 @@ html, body {
     height: auto;
 }
 
+html {
+    font-size: 100px;
+}
+
 ::-webkit-scrollbar {
   width: 0;
 }
+
 #app {
     max-width: 4.02rem;
     width: 100vw;

+ 11 - 11
src/utils/index.ts

@@ -2,18 +2,18 @@
 export const setHtmlFontSize = () => {
     console.count("setHtmlFontSize");
     (function (doc, win) {
-        var htmlDom = doc.getElementsByTagName("html")[0],
-            resizeEvt = "orientationchange" in win ? "orientationchange" : "resize",
-            recalc = function () {
-                requestAnimationFrame(() => {
-                    var clientWidth = doc.documentElement.clientWidth || doc.body.clientWidth;
-                    if (!clientWidth) return;
-                    htmlDom.style.fontSize = clientWidth>=578.88 ? '144px' : 154.5 * (clientWidth / 578.88) + 'px';
-                })
-            };
+        let resizeEvt = "orientationchange" in win ? "orientationchange" : "resize",
+        recalc = function () {
+            let htmlDom = doc.getElementsByTagName("html")[0]
+            requestAnimationFrame(() => {
+                let clientWidth = doc.documentElement.clientWidth || doc.body.clientWidth;
+                if (!clientWidth) return;
+                htmlDom.style.fontSize = clientWidth>=578.88 ? '144px' : 154.5 * (clientWidth / 578.88) + 'px';
+            })
+        };
         if (!doc.addEventListener) return;
         win.addEventListener(resizeEvt, recalc, false);
-        doc.addEventListener('DOMContentLoaded', recalc, false);
-        setTimeout(()=>recalc(),1000)
+        doc.addEventListener('DOMContentLoaded', recalc, false);   
+        recalc()   
     })(document, window);
 };