house
This commit is contained in:
12
src/utils/rem.ts
Normal file
12
src/utils/rem.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
// 设计稿 1920px
|
||||
const baseWidth = 1920;
|
||||
const baseFontSize = 16;
|
||||
|
||||
function setRem() {
|
||||
const scale = document.documentElement.clientWidth / baseWidth;
|
||||
const fontSize = baseFontSize * scale;
|
||||
document.documentElement.style.fontSize = fontSize + 'px';
|
||||
}
|
||||
|
||||
window.addEventListener('resize', setRem);
|
||||
setRem();
|
||||
Reference in New Issue
Block a user