Refactor code structure and remove redundant changes
This commit is contained in:
11
utils/rem.ts
Normal file
11
utils/rem.ts
Normal file
@ -0,0 +1,11 @@
|
||||
// 设置 rem 函数
|
||||
function setRem() {
|
||||
// 1920 默认大小16px; 1920px = 120rem ;每个元素px基础上/16
|
||||
const screenWidth = 1920
|
||||
const scale = screenWidth / 16
|
||||
const htmlWidth = window.screen.width
|
||||
// 得到html的Dom元素
|
||||
const htmlDom = document.getElementsByTagName('html')[0]
|
||||
// 设置根元素字体大小
|
||||
htmlDom.style.fontSize = htmlWidth / scale + 'px'
|
||||
}
|
||||
Reference in New Issue
Block a user