zoukankan      html  css  js  c++  java
  • 首次写iPad布局感想(H5)

    一直做前端工作,却从来没有开发过平板的项目,想来也是有遗憾的,孰知,新公司的第二个项目就是要适配平板,刚开始是懵的,对于兼容,感觉是自己的短板,但庆幸的是这一版只需要兼容iOS系统就可以。

    那我现在就说下开发iOS h5项目可能会进到的误区(知道很菜,但是写出来也是对自己加深印象)

    - ios的专有meta

    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="format-detection" content="telephone=no" />
    ......列举常用,其他用时可百度

    不要以为引入<meta name="viewport" content="target-densitydpi=device-dpi, width=device-width, initial-scale=1, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">对于禁止屏幕缩放就万事大吉了,这只针对于谷歌浏览器,要想兼容苹果自带的Safari还需要写入下面这段代码

        window.onload=function () {
          document.addEventListener('touchstart',function (event) {
            if(event.touches.length>1){
              event.preventDefault();
            }
          })
          var lastTouchEnd=0;
          document.addEventListener('touchend',function (event) {
            var now=(new Date()).getTime();
            if(now-lastTouchEnd<=300){
              event.preventDefault();
            }
            lastTouchEnd=now;
          },false)
        }

    - button、input、textarea触发时的灰色背景块(高亮显示)
    这都是需要我们去禁止的,毕竟要还原设计稿嘛,这是就要加入这几个属性

      -webkit-appearance: none;
      outline: none;
      -webkit-tap-highlight-color: rgb(0, 0, 0, 0);透明度需要为0
      -webkit-user-modify: read-write-plaintext-only;

    - 页面滚动效果
    如果在需要滚动的区块内添加了overflow: auto;这个样式
    肯定会发现滚动的效果不是很流畅,这时就需要在body上添加一个样式overflow-x: hidden; 实现方式不止一种 也可以在滚动快上添加webkit-overflow-scrolling: touch;

  • 相关阅读:
    P1309 瑞士轮 (吸氧了)
    P1158 导弹拦截
    腾讯笔试题 构造回文(LCS问题)
    蓝桥杯之大臣的旅费(两次dfs)
    蓝桥杯之买不到的数目(数学公式或缩小范围+暴力)
    蓝桥杯之翻硬币(思维,找规律,贪心)
    蓝桥杯之 连号区间数(巧妙遍历)
    蓝桥杯之剪格子(经典dfs)
    蓝桥杯之带分数(全排列+暴力)
    面试题之O(n)内旋转字符串
  • 原文地址:https://www.cnblogs.com/10manongit/p/12890490.html
Copyright © 2011-2022 走看看