123
This commit is contained in:
@@ -2,7 +2,9 @@ import { getUniversalZoomLevel } from '@/utils/tools'
|
||||
|
||||
const maxWidth = 1920;
|
||||
const minWidth = 500;
|
||||
let flexible = (designWidth = 1920) => {
|
||||
const maxHeight = 1080;
|
||||
const minHeight = 500;
|
||||
let flexible = (designWidth = 1920, designHeight = 1080) => {
|
||||
var doc = document, win = window, docEl = doc.documentElement, remStyle = document.createElement("style"), tid;
|
||||
function refreshRem() {
|
||||
var width = docEl.getBoundingClientRect().width;
|
||||
@@ -11,7 +13,11 @@ let flexible = (designWidth = 1920) => {
|
||||
height = getUniversalZoomLevel() * height
|
||||
if (width > maxWidth) width = maxWidth;
|
||||
if (width < minWidth) width = minWidth;
|
||||
var rem = (width * 10 / designWidth).toFixed(2);
|
||||
if (height > maxHeight) height = maxHeight;
|
||||
if (height < minHeight) height = minHeight;
|
||||
const wrem = (width * 10 / designWidth).toFixed(2);
|
||||
const hrem = (height * 10 / designHeight).toFixed(2);
|
||||
const rem = Math.min(wrem, hrem);
|
||||
docEl.style.fontSize = rem + 'px'
|
||||
}
|
||||
//要等 wiewport 设置好后才能执行 refreshRem,不然 refreshRem 会执行2次;
|
||||
|
||||
Reference in New Issue
Block a user