From 3f0472517de3a37ef6b9a9be8626f3adae0ebd9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?TOP=E7=B3=AF=E7=B1=B3?= <1130395124@qq.com> Date: Wed, 11 Oct 2023 19:46:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9Erem=E6=8D=A2=E7=AE=97?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/main.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/js/main.js b/js/main.js index 25f5202..10b951a 100644 --- a/js/main.js +++ b/js/main.js @@ -33,6 +33,22 @@ function hideMenu() { } $(function () { + function setRem() { + var whdef = 100 / 1920;// 表示1920的设计图,使用100PX的默认值 1rem = 100px + var wH = window.innerHeight;// 当前窗口的高度 + var wW = window.innerWidth;// 当前窗口的宽度 + var rem = wW * whdef;// 以默认比例值乘以当前窗口宽度,得到该宽度下的相应FONT-SIZE值 + $('html').css('font-size', rem + "px"); + $(window).resize(function () { + var whdef = 100 / 1920;// 表示1920的设计图,使用100PX的默认值 + var wH = window.innerHeight;// 当前窗口的高度 + var wW = window.innerWidth;// 当前窗口的宽度 + var rem = wW * whdef;// 以默认比例值乘以当前窗口宽度,得到该宽度下的相应FONT-SIZE值 + $('html').css('font-size', rem + "px"); + }); + } + setRem(); + $('.header .menu-group').load('../common/header.html'); $('.footer').load('../common/footer.html'); $(window).scroll(function () {