标签:
方法一:用css3的媒体查询来设置
html {font-size:12px} @media screen and (min-width:480px) and (max-width:639px) {html {font-size: 15px;}} @media screen and (min-width:640px) and (max-width:719px) {html {font-size: 20px;}} @media screen and (min-width:720px) and (max-width:749px) {html {font-size: 22.5px;}} @media screen and (min-width:750px) and (max-width:799px) {html {font-size: 23.5px;}} @media screen and (min-width:800px) and (max-width:959px) {html {font-size: 25px;}} @media screen and (min-width:960px) and (max-width:1079px) {html {font-size: 30px;}} @media screen and (min-width: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";
标签:
原文地址:http://www.cnblogs.com/rainheader/p/4629470.html