哪些你不知道的移动开发属性
<meta name=”viewport” content=”width=device-width, initial-scale=1.0″/> 让内容的宽度自适应为设备的宽度, 在做Mobile Web时必须加的一条
<meta name=”format-detection” content=”telephone=no”]]> 禁用手机号码链接(for iPhone)
<link rel=”apple-touch-icon” href=”icon.png”/> 设置你网页的图标, 尺寸为57X57 px
<!– iOS 2.0+: tell iOS not to apply any glare effects to the icon –>
<link rel=”apple-touch-icon-precomposed” href=”icon.png”/>
<!– iOS 4.2+ icons for different resolutions –>
<link rel=”apple-touch-icon” sizes=”72×72″ href=”touch-icon-ipad.png” />
<link rel=”apple-touch-icon” sizes=”114×114″ href=”touch-icon-iphone4.png” />
<link rel=”apple-touch-startup-image” href=”startup.png”> 全屏启动时候的启动画面图像, 尺寸320X460 px
<meta name=”apple-mobile-web-app-capable” content=”yes” /> 是否允许全屏显示, 只有在桌面启动时可用
<meta name=”apple-mobile-web-app-status-bar-style” content=”black” /> 控制全屏时顶部状态栏的外观, 默认白色
<input autocorrect=”off” autocomplete=”off” autocapitalize=”off”>
<input type=”text” x-webkit-speech /> 语音输入
<input type=”file” accept = “image ::-webkit-scrollbar { width: 12px; } ::-webkit-scrollbar-track { -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3); -webkit-border-radius: 10px; border-radius: 10px; } ::-webkit-scrollbar-thumb { -webkit-border-radius: 10px; border-radius: 10px; background: rgba(255,0,0,0.8); -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.5); } ::-webkit-scrollbar-thumb:window-inactive { background: rgba(255,0,0,0.4); }
-webkit-background-composite: plus-darker; -webkit-background-composite用来设置一个元素的背景或颜色的组合样式
-webkit-text-stroke:
-webkit-mask-image:
-webkit-box-reflect:
:local-link {font-weight: normal;}
Javascript:
window.scrollTo(0,0); 隐藏地址栏
window.matchMedia(); 匹配媒体
navigator.connection; 决定手机是否运行在WiFi/3G等网络
window.devicePixelRatio; 决定屏幕分辨率(iPhone 4值为2, 而Nexus One值为1.5)
window.navigator.onLine; 取得网络连接状态
window.navigator.standalone; 决定iPhone是否处于全屏状态
touch事件 (iOS, Android 2.2+): touchstart, touchmove, touchend, touchcancel
gesture事件 (Apple only, iOS 2+):
window.addEventListener(“orientationchange”, function(e){ //window.orientation(0 is portrait, 90 and -90 are landscape) }, false); window.addEventListener(“deviceorientation”, function(e){ //e.alpha //e.beta //e.gamma }, false); window.addEventListener(“devicemotion”, function(e){ //e.accelerationIncludingGravity.x //e.accelerationIncludingGra vity.y //e.accelerationIncludingGra vity.z }, false);
requestAnimationFrame() 新的动画函数
element.webkitRequestFullScreen() 调用全屏函数