[html5]
代码比较简单就不贴了 总结下注意事项:
1. 使用 rem 单位布局
js:document.documentElement.style.fontSize = document.documentElement.clientWidth / 16 + 'px'; //16 是我根据自己的风格定义的 如果你是 640X1136(iphone5) 的图就改成 6.4
2. 弹出层用的是 js 动态定位 (追求效率, 用的以前封装的方法)
- // 居中显示弹出层
- function popBox(id){
- var w =$(id).width();
- var h =$(id).height();
- var t = scrollY() +(windowHeight()/2)-(h/2);
- if(t<0)t=0;
- var l = scrollX()+((windowWidth())-(w))/2;
- if(l<0) l=0;
- $(id).CSS({left:l/20+'rem',top:t/20+'rem'});
- $(id).css('display','block');
- }
- // 浏览器视口的高度 (兼容写法 - male)
- function windowHeight() {
- var de = document.documentElement;
- return self.innerHeight || (de && de.clientHeight) || document.body.clientHeight;
- }
- // 浏览器视口的宽度 (兼容写法 - male)
- function windowWidth() {
- var de = document.documentElement;
来源: http://www.qdfuns.com/article/20813/eb8361d0a0184f3c428509698a4a582f.html