1. /*REM单位换算方法 iphone6适配*/
  2.  
  3. function resizeRoot(){
  4. var Dpr = 1, uAgent = window.navigator.userAgent;
  5. var isIOS = uAgent.match(/iphone/i);
  6. var wWidth = (screen.width > 0) ? (window.innerWidth >= screen.width || window.innerWidth == 0) ? screen.width : window.innerWidth : window.innerWidth, wDpr, wFsize;
  7. if (window.devicePixelRatio) {
  8. wDpr = window.devicePixelRatio;
  9. } else {
  10. wDpr = isIOS ? wWidth > 818 ? 3 : wWidth > 480 ? 2 : 1 : 1;
  11. }
  12. if(isIOS) wWidth = screen.width;
  13. wFsize = wWidth > 1080 ? 144 : wWidth / 7.5;
  14. window.screenWidth_ = wWidth;
  15. document.getElementsByTagName('html')[0].dataset.dpr = wDpr;
  16. document.getElementsByTagName('html')[0].style.fontSize = wFsize + 'px';
  17. }
  18. //判断安卓手机浏览器低版本的用ready方法执行
  19. function appsion(){
  20. uAgent = window.navigator.userAgent;
  21. var isIOS = uAgent.match(/iphone/i);
  22. if(navigator.appVersion.substring(navigator.appVersion.length-6)<537 && !isIOS){
  23. document.ready=function(){
  24. resizeRoot();
  25. }
  26. }else{
  27. resizeRoot();
  28. }
  29. }
  30. appsion();
  31. //rem配置方法执行

计算APP高度

  1. var winWidth = 0;
  2. var winHeight = 0;
  3. function findDimensions() //函数:获取尺寸
  4. {
  5. //获取窗口宽度
  6. if (window.innerWidth)
  7. winWidth = window.innerWidth;
  8. else if ((document.body) && (document.body.clientWidth))
  9. winWidth = document.body.clientWidth;
  10. //获取窗口高度
  11. if (window.innerHeight)
  12. winHeight = window.innerHeight;
  13. else if ((document.body) && (document.body.clientHeight))
  14. winHeight = document.body.clientHeight;
  15. //通过深入Document内部对body进行检测,获取窗口大小
  16. if (document.documentElement && document.documentElement.clientHeight && document.documentElement.clientWidth)
  17. {
  18. winHeight = document.documentElement.clientHeight;
  19. winWidth = document.documentElement.clientWidth;
  20. }
  21. //结果输出至两个文本框
  22. }
  23. findDimensions();
  24. //调用函数,获取数值
  25. window.onresize=findDimensions;
  26. function loadAddButton(id){
  27. // window.onload=function(){
  28. var d1=document.getElementById(id);
  29. var h1=d1.clientHeight+d1.scrollHeight;
  30. var h2=d1.offsetHeight+40;
  31. var wheight = winHeight;
  32.  
  33. if(h2<wheight){
  34. // alert(wheight);
  35. // alert("wheight:"+wheight);
  36. // alert("wheight:"+wheight);
  37. document.getElementById(id).style.height=wheight+"px";
  38. }else {//alert("h2:"+h2);
  39. document.getElementById(id).style.height=h2+"px";
  40. }
  41. //}
  42. }
  43.  
  44. function loadAddlist(id,height){
  45. findDimensions();
  46. var wheight = winHeight - height;
  47. document.getElementById(id).style.height=wheight+"px";
  48. }
  49. function bodyheight(){
  50. findDimensions();
  51. var body = document.getElementsByTagName("body")[0];
  52. body.style.height=winHeight+"px";
  53. }
  54.  
  55. function getBodyheight(){
  56. findDimensions();
  57. return winHeight;
  58. }
  59. jQuery(function(){
  60. bodyheight();
  61. addEvent(window, 'resize', function () {
  62. setTimeout(function(){
  63. bodyheight();
  64. },300);
  65. });
  66. });
  67. function addEvent(e, n, o){
  68. if(e.addEventListener){
  69. e.addEventListener(n, o,false);
  70. } else if(e.attachEvent){
  71. e.attachEvent('on' + n, o);
  72. }
  73. }

页面用rem为单位写,但注意点:

1.最外面的宽度用百分比,最好不要用rem

2.input中line-height不要用,如果字被截,那把文字大小缩小

3.高度要用rem

H5中REM中使用的规则的更多相关文章

  1. css3中rem和em是干嘛的

    css3中rem和em是干嘛的 一.总结 一句话总结:对rem综合评价是用来做web app它绝对是最合适的人选之一. 这里我特别强调web app,web page就不能使用rem吗,其实也当然可以 ...

  2. 详解 Python 中的下划线命名规则

    在 python 中,下划线命名规则往往令初学者相当 疑惑:单下划线.双下划线.双下划线还分前后……那它们的作用与使用场景 到底有何区别呢?今天 就来聊聊这个话题. 1.单下划线(_) 通常情况下,单 ...

  3. 【转载】C#中自定义Sort的排序规则IComparable接口

    C#中的List集合在排序的时候,如果不使用Lambda表达式进行排序的话,一般调用Sort()方法进行排序,如果希望Sort()方法排序后的结果跟我们预想的效果一致或者按照我们自定义的规则排序,则需 ...

  4. 5 个关于 API 中日期和时间设计规则

    规则 #1 使用ISO-8601格式作为你的日期格式 ISO 8601 解决了很多问题,包括: 自然排序 - 简单和优雅,免去多余的工作即可实现排序 时区偏移 - 代表用户的地点和时区在日益增长的全球 ...

  5. Firewalld中的whitelist并不是规则白名单

    原文地址:http://www.excelib.com/article/292/show whitelist的含义 白名单跟防火墙结合在一起大家很容易将其理解为规则白名单,不过在Firewalld中w ...

  6. CSS中rem、em的区别

    引用文档:http://www.divcss5.com/html/h529.shtml:http://blog.csdn.net/qq_35432904/article/details/5180422 ...

  7. [转帖]关于Java中SQL语句的拼接规则

    关于Java中SQL语句的拼接规则 自学demo 的时候遇到的问题 结果应该是 '"+e.getName()+"' 注意 一共有三组标点符号 (除去 方法函数后面的括号) 实现目标 ...

  8. HLSL中constant variables的packing规则

    HLSL中constant variables的packing规则 参考MSDN上的官方文档.一般而言,HLSL将数据打包为4字节对齐,此外,它不允许数据跨16字节(即4个float的vector)的 ...

  9. background,position,绝对定位中位置属性的定位规则,cursor

    backgorund背景 background-color:red; 背景颜色 background-image:url(路径);背景图片 background-repeat:no-repeat;不重 ...

随机推荐

  1. [Think In Java]基础拾遗1 - 对象初始化、垃圾回收器、继承、组合、代理、接口、抽象类

    目录 第一章 对象导论第二章 一切都是对象第三章 操作符第四章 控制执行流程第五章 初始化与清理第六章 访问权限控制第七章 复用类第九章 接口 第一章 对象导论 1. 对象的数据位于何处? 有两种方式 ...

  2. end2end learning 端到端学习

    在DeepLearning的文章中有看到end2end一次,作者们似乎都比较喜欢这个end2end learning的方式.那么到底啥是end2end? 找了一下相关论文,没找到专门讲这个概念的,看来 ...

  3. ReactNative 当前url和cookies的获取

    前面大概介绍了react-native的运行helloword级别的入门,所以之后简单的东西就不写了,毕竟官网上都能够找到. reactnative官网:https://facebook.github ...

  4. sublime text 3 3114 注册码

    -– BEGIN LICENSE -– Michael Barnes Single User License EA7E-821385 8A353C41 872A0D5C DF9B2950 AFF6F6 ...

  5. 聊聊HTTPS和SSL/TLS协议

    要说清楚 HTTPS 协议的实现原理,至少需要如下几个背景知识.1. 大致了解几个基本术语(HTTPS.SSL.TLS)的含义2. 大致了解 HTTP 和 TCP 的关系(尤其是“短连接”VS“长连接 ...

  6. angularjs自带过滤器

    filter: filter过滤器第一个参数若是对象: <ul> <li ng-repeat="friend in friends | filter:{'name':'Jo ...

  7. arcgis engine 监听element的添加、更新和删除事件(使用IGraphicsContainerEvents)

    IGraphicsContainerEvents Interface 如何监听 element事件? 如,当我们在Mapcontrol上添加.删除.更新了一个Element后,如何捕捉到这个事件?   ...

  8. Solve

    /// <summary> /// Solves this instance. /// </summary> /// <returns>IFeatureClass. ...

  9. redis教程(整理中)

    一.redis简介 1.Redis:键值对类型的内存数据库:应用于高并发和实时请求的场景: 2.Redis常用数据类型: (1) string(基本数据类型)     (2)hash 注:hash中的 ...

  10. morse code

    morse code,摩斯电码,是一种时通时断的信号代码,通过不同的排列顺序来表达不同的英文字母.数字和标点符号. 摩斯电码,是一种早期的数字化通信形式,但是它不同于现代只使用0和1两种状态的二进制代 ...