方法一

  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";
}

方法二

; (function (doc, win) {
var html = doc.documentElement, //html
resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
recalc = function () {
var hWidth = html.getBoundingClientRect().width;
if (!hWidth) return;
hWidth = Math.min(540, hWidth);
html.style.fontSize = (hWidth / 10) + 'px';
};
if (!doc.addEventListener) return;
win.addEventListener(resizeEvt, recalc, false);
recalc();
})(document, window);

最新文章

  1. 【poj2154】 Color
  2. Haskell 参考资料
  3. 获取系统开机的时间(Windows、Linux)
  4. Linux网络管理——IP地址
  5. BZOJ 3384: [Usaco2004 Nov]Apple Catching 接苹果( dp )
  6. 笔记28 mssql的update :from语法
  7. Python3基础 list(reversed()) 将一个列表逆转并输出
  8. Servlet实现文件上传(多文件)(三)
  9. 彻底清除Linux centos minerd木马
  10. gulp总结
  11. poj1265&&2954 [皮克定理 格点多边形]【学习笔记】
  12. J2EE Exception:WELD-001408 Unsatisfied dependencies for type [SelectModelFactory] with qualifiers [@
  13. Virtual box中Ubuntu虚拟机磁盘碎片整理和空间清理方法
  14. oracle分区表的使用和查询
  15. Maven项目下servlet异常
  16. centos7 redmine安装过程
  17. windows设置电脑的固定IP
  18. 1-安装MQTT服务器(Windows),并连接测试
  19. keeplived工作原理及配置
  20. jedisClient操作redis实现增删改查功能

热门文章

  1. 我的Java开发学习之旅------>Java经典排序算法之归并排序
  2. (转)source insight 窗口嵌入
  3. Swift 烧脑体操(四) - map 和 flatMap
  4. 【Leetcode-easy】Valid Parentheses
  5. ASP.Net .Net4.0 HTTP 错误 404.17 - Not Found
  6. Shell 特殊位置参数的变量
  7. 51Nod 1158 全是1的最大子矩阵 —— 预处理 + 暴力枚举 or 单调栈
  8. c语言学习的第13天1
  9. 前端多媒体(1)——获取摄像头&麦克风
  10. java面试题05