码迷,mamicode.com
首页 > Web开发 > 详细

用js判断屏幕的宽度,改变html字体大小用rem布局

时间:2018-12-19 11:09:58      阅读:226      评论:0      收藏:0      [点我收藏+]

标签:改变   大于   字体   htm   居中   idt   font   rem   else   

if (document.documentElement.clientWidth > 600) {//页面宽度大于600px让其宽度等于600px,字体大小等于60px,居中
document.documentElement.style.width = "600px";
document.documentElement.style.fontSize = "60px";
document.documentElement.style.margin = "0 auto";
} else {//否则让其根节点字体大小等于宽度/10px
document.documentElement.style.fontSize = document.documentElement.clientWidth / 10 + "px";
}

用js判断屏幕的宽度,改变html字体大小用rem布局

标签:改变   大于   字体   htm   居中   idt   font   rem   else   

原文地址:https://www.cnblogs.com/hyx626/p/10141557.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!