You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
511 B

11 months ago
function fn(){
console.log(11111);
function setHtmlFontSize() {
let whdef = 100 / 1920 ;
let bodyWidth = document.documentElement.getBoundingClientRect().width;
console.log(bodyWidth,'屏幕宽度')
let rem = bodyWidth * whdef
document.getElementsByTagName('html')[0].style.fontSize = rem + 'px'
}
setHtmlFontSize()
window.addEventListener('resize',function(){
setTimeout(function(){
setHtmlFontSize()
},100)
})
}
fn()