@hotjp
2017-06-15T08:32:56.000000Z
字数 3317
阅读 1613
移动端 培训
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
远程拉取dtd的方式是XHTML的写法,正常开发使用下面的html5 doctype
<!doctype html>
使用viewport设置视口,控制内容宽度、缩放比例等
完整的viewprot设置
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0">
最后一个参数写成 0 或 no 都可以。
<meta name="apple-mobile-web-app-capable" content="yes">
如果 content 设置为 yes ,web应用将以全屏模式运行,反之,则不会。content 的默认值是 no ,可以通过js查询只读只读属性来确定app是否全屏模式显示。
window.navigator.standalone
<meta name="apple-mobile-web-app-status-bar-style" content="black">
仅在全屏模式下生效 (ios2.1+)
共有三种 content :
<!--上下分开,白背景--><meta name="apple-mobile-web-app-status-bar-style" content="default"><meta name="apple-mobile-web-app-status-bar-style" content="blank">
<!--透明--><meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<!--颜色--><meta name="apple-mobile-web-app-status-bar-style" content="white">
使用 format-detection 来启用或禁用自动识别页面中的电话号码和邮箱(所有移动端都支持,只有ios默认on)
<meta name="format-detection" content="telephone=no"><meta name="format-detection" content="email=no">
element{-webkit-appearance:none;}
<link rel="apple-touch-icon" href="touch-icon-iphone.png"><link rel="apple-touch-icon" size="76x76" href="touch-icon-ipad.png"><link rel="apple-touch-icon" size="120x120" href="touch-icon-iphone-retina.png"><link rel="apple-touch-icon" size="152x152" href="touch-icon-ipad-retina.png">
a标签一定要有href,非a标签可加cursor:pointer,或者套一层a标签
<a href="javascript:;">点我点我</a><div style="cursor:pointer">点我点我</div><a href="javascript:;"><div>点我点我</div></a>
上下滑动卡顿或者慢的时候
body{-webkit-overflow-scrolling:touch;overflow-scrolling:touch;}
其他需要滚动的元素同理。
移动端简版:
element{-webkit-user-select:none;user-select:none;}
全移动端浏览器版本:
element{-webkit-user-select:none;-moz-user-select:none;-khtml-user-select:none;user-select:none;}
touch元素时会有灰色半透明遮罩,某些国产浏览器下是蓝色的。
element{-webkit-tap-highlight-color:rgba(255,255,255,0);}
<body ontouchstart="">
<style>a{color:#000;}a:active{color:#fff;}</style><a href="#">xx</a><script>document.addEventListener("touchstart",function(){},false);</script>
主要用于css3动画的加速
element{-webkit-transform:translate3d(0,0,0);transform:translated3d(0,0,0);}
element{border-width:thin;}
*{-webkit-text-size-adjust:100%;}
<meta http-equiv="cache-control" content="no-cache">
<!--全屏--><meta name="x5-fullscreen" content="true"><!--强制竖屏--><meta name="x5-orientation" content="portrait"><!--强制横屏--><meta name="x5-orientation" content="landscape"><!--应用模式--><meta name="x5-page-mode" content="app">
<!--全屏--><meta name="full-screen" content="yes"><!--强制竖屏--><meta name="screen-orientation" content="portrait"><!--强制横屏--><meta name="screen-orientation" content="landscape"><!--应用模式--><meta name="browsermode" content="application">
不识别viewport的设备优化
<meta name="HandheldFriendly" content="true">
微软老式浏览器
<meta name="MobileOptimized" content="320">
windows phone 取消点击高光
<meta name="msapplication-tap-highlignt" content="no">
包含 keydown , keyup , keypress 支持问题。
建议使用html5的 input 事件去代替 keyup
<input type="text" id="foo"><script>document.getElementById("foo").addEventListener("input",function(e){var value = e.target.value;});</script>
自XHTML 2.0第六版开始写入W3C草案。
2008年正式成为W3C标准。
对于实例对象的抽象化。