1 //得到手机屏幕的宽度 2 let htmlWidth = document.documentElement.clientWidth || document.body.clientWidth; 3 if(htmlWidth>750){htmlWidth=750} 4 //得到html的Dom元素 5 let htmlDom = document.getElementsByTagName('html')[0]; 6 //设置根元素字体大小 7 htmlDom.style.fontSize = htmlWidth/20 + 'px'; 8 htmlDom.style.margin = '0 auto'; 9 htmlDom.style.maxWidth = 750 + 'px';
js控制手机端字体大小rem
猜你喜欢
转载自www.cnblogs.com/e-cat/p/9199678.html
今日推荐
周排行