<!DOCTYPE html>
<html lang="zh"> <head>
<meta charset="UTF-8">
<title>rem phone test</title>
<meta name="viewport" content="user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<style>
html {
height: 100%;
width: 100%;
font-family: 'Heiti SC', 'Microsoft YaHei';
font-size: 20px;
overflow: hidden;
outline: 0;
-webkit-text-size-adjust:none;
}
body {
height: 100%;
margin: 0 auto;
overflow: auto;
-webkit-user-select: none;
position: relative;
}
header,footer {
width: 100%;
line-height: 1.5rem;
font-size: 1rem;
color: #000;
border: 1px solid #ccc;
text-align: center;
font-weight:bold;">#ccc;
}
.bd {
margin-top: 1rem;
margin-bottom: .5rem;
margin-right: -.5rem;
font-size: 0;
}
.box {
width: 5rem;
height: 5rem;
display: inline-block;
margin-right:0.5rem;
margin-bottom:0.5rem;
}
.blue-box {
font-weight:bold;
       background-color:red;
}
.org-box {
font-weight:bold;
    background-color:blue;
}
</style>
</head>
<body>
<header>我是头部</header>
<div class="bd">
<div class="box blue-box"></div>
<div class="box red-box"></div>
<div class="box blue-box"></div>
<div class="box red-box"></div>
<div class="box blue-box"></div>
<div class="box red-box"></div>
</div>
<footer>我是页脚</footer>
<script>
(function (doc, win) {
//获取根节点,将它赋值给一个变量
var docEl = doc.documentElement,
//利用三目运算来判断window中是否有这个事件,将它赋值给变量
//orientationchange()是改变窗口的方向
//resize()是计算窗口改变了多少次
resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
recalc = function () {
//获取可视区域的宽度
var clientWidth = docEl.clientWidth;
//进行判断是否要执行下面的换算
if (!clientWidth){
//0 undefined "" 都会返回false
return;
}
//进行单位的换算,通过窗口的变化,来进行根节点的单位变化
docEl.style.fontSize = 20 * (clientWidth / 320) + 'px';
};
if (!doc.addEventListener){
return;
}
win.addEventListener(resizeEvt, recalc, false);
doc.addEventListener('DOMContentLoaded', recalc, false);
})(document, window); //匿名函数的传参
</script>
</body> </html>

最新文章

  1. 应用r.js来优化你的前端
  2. java虚拟机启动参数分类详解
  3. 使用autolayout,设置子控件的宽度 与父视图的宽度成比例大小(这样类似可以设置多个按钮平均横屏排列)
  4. Network Address Translation(转载)
  5. PHP - 如何使用XDEBUG来远程调试?
  6. 将Log4net的配置配置到的独立文件中
  7. 用ultraISO 制作一个MSdos启动软盘镜像
  8. 【linux】Ubuntu 14.04 smba服务器的配置
  9. CarDAQ-Plus
  10. DHU-1241 Oil Deposits
  11. nginx配置中文域名解析
  12. HDOJ 1312 (POJ 1979) Red and Black
  13. Android忽略文件以及.gitignore规则不生效的可行解决方案
  14. Spring Boot 2.x中的management.security.enabled=false无效问题
  15. Windows平台下nginx跨域配置
  16. Bundle类解读
  17. ArduinoYun教程之通过网络为Arduino Yun编程
  18. 5 -- Hibernate的基本用法 --2 Hibernate入门
  19. MVC扩展生成CheckBoxList并水平排列
  20. configure: error: png.h not found.

热门文章

  1. Centos上的安装openoffice+unoconv+swftools (转)
  2. Visual Studio 2008打开vs2010解决方案的方法
  3. iOS流量精灵完结版
  4. javascript高级教程:如何优化javascript代码性能
  5. mysql alter 语句用法,添加、修改、删除字段等
  6. IOS_画图 图片等比压缩 IOS_UIImage
  7. MVC的过滤器
  8. asp.net 动态添加自定义控件
  9. net_device 结构体分析
  10. Map/Reduce个人实战--生成数据测试集