zoukankan      html  css  js  c++  java
  • 移动端知识点总结

    一,meta标签
    <meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0, user-scalable=no"> 定义这个东西,让他屏幕大小适应手机端
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes"><!-- 删除苹果默认的工具栏和菜单栏 -->
    <meta name="apple-mobile-web-app-status-bar-style" content="black"><!-- 设置苹果工具栏颜色 -->
    <meta name="format-detection" content="telphone=no, email=no"><!-- 忽略页面中的数字识别为电话,忽略email识别 -->
    <!-- 启用360浏览器的极速模式(webkit) -->
    <meta name="renderer" content="webkit">
    <!-- 避免IE使用兼容模式 -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- 针对手持设备优化,主要是针对一些老的不识别viewport的浏览器,比如黑莓 -->
    <meta name="HandheldFriendly" content="true">
    <!-- 微软的老式浏览器 -->
    <meta name="MobileOptimized" content="320">
    <!-- uc强制竖屏 -->
    <meta name="screen-orientation" content="portrait">
    <!-- QQ强制竖屏 -->
    <meta name="x5-orientation" content="portrait">
    <!-- UC强制全屏 -->
    <meta name="full-screen" content="yes">
    <!-- QQ强制全屏 -->
    <meta name="x5-fullscreen" content="true">
    <!-- UC应用模式 -->
    <meta name="browsermode" content="application">
    <!-- QQ应用模式 -->
    <meta name="x5-page-mode" content="app">
    <!-- windows phone 点击无高光 -->
    <meta name="msapplication-tap-highlight" content="no">
    <!-- 适应移动端end -->
    <meta name="nightmode" content="enable/disable">
    <meta name="imagemode" content="force">
    <!-- 禁用掉uc浏览器判断到页面上文字居多时,会自动放大字体优化移动用户体验。 -->
    <meta name="wap-font-scale" content="no">

    二,取消表单元素在点击态时的边框以及半透明灰色背景

    css代码:

    input, textarea, button, a{ 
      -webkit-tap-highlight-color:rgba(0,0,0,0); 
    }
    

    三,移除原生控件样式

    css代码:

    input,button,textarea {
        -webkit-appearance: none;
    }
    

    四,使用rem来做响应式开发

    scss代码:

    html {
      font-size: $baseFontSize;
      @media screen and (min- 320px) {
        font-size: $baseFontSize*.9;
      }
      @media screen and (min- 360px) {
        font-size: $baseFontSize;
      }
      @media screen and (min- 400px) {
        font-size: $baseFontSize*1.1;
      }
    }
    

    五,定义字体

    如无特殊需求,手机端无需定义中文字体,使用系统默认;

    英文字体和数字字体可使用 Helvetica ,三种系统(ios、android、winphone)都支持。

    css代码:

    body{
        font-family: Helvetica;
    }
    

    六,移动端touch事件

    当用户手指放在移动设备在屏幕上滑动会触发的touch事件
    touchstart:当手指触碰屏幕时候发生。不管当前有多少只手指
    touchmove:当手指在屏幕上滑动时连续触发。通常我们再滑屏页面,会调用event的preventDefault()可以阻止默认情况的发生:阻止页面滚动
    touchend:当手指离开屏幕时触发
    touchcancel:系统停止跟踪触摸时候会触发。例如在触摸过程中突然页面alert()一个提示框,此时会触发该事件,这个事件比较少用

    七,click产生200-300 ms的延迟响应

    页面js捕获click事件的回调函数处理,需要300ms后才生效
    解决方案:
    1、fastclick可以解决在手机上点击事件的300ms延迟
    2、zepto的touch模块,tap事件也是为了解决在click的延迟问题

    八,媒体查询判断横竖屏

    代码:

    @media all and (orientation :landscape){
    ...
    }
    
    
    @media all and (orientation :portrait){
    ...
    }
    

      

     

  • 相关阅读:
    时间日期事件处理、长按事件
    单选按钮触发事件、下拉列表触发事件
    事件
    笔记3
    笔记2
    笔记1
    布局管理器
    08、shell三剑客之sed
    07、shell三剑客之grep
    06、shell正则表达式
  • 原文地址:https://www.cnblogs.com/keleyz/p/5198882.html
Copyright © 2011-2022 走看看