怎么设置(控制)移动端的字体大小

方法一:用css3的媒体查询来设置

html {font-size:12px}
@media screen and (min-480px) and (max-639px) {html {font-size: 15px;}}
@media screen and (min-640px) and (max-719px) {html {font-size: 20px;}}
@media screen and (min-720px) and (max-749px) {html {font-size: 22.5px;}}
@media screen and (min-750px) and (max-799px) {html {font-size: 23.5px;}}
@media screen and (min-800px) and (max-959px) {html {font-size: 25px;}}
@media screen and (min-960px) and (max-1079px) {html {font-size: 30px;}}
@media screen and (min-1080px) {html {font-size: 32px;}}

方法二:用js来设置

/*

*** 12为最小字体大小

*** 40为最大字体大小

*** 320屏幕下font-size是12

*/

document.getElementsByTagName('html')[0].style.fontSize = Math.min(window.innerWidth*12/320,40)+"px";

  

原文地址:https://www.cnblogs.com/rainheader/p/4629470.html