Meta設置css
<!-- 設備寬度、禁止縮放 --> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" /> <!-- 是否刪除蘋果工具欄和菜單欄(yes/no) --> <meta name="apple-mobile-web-app-capable" content="yes" /> <!-- 蘋果頂部導航欄顏色(default/black/black-translucent) --> <meta name="apple-mobile-web-app-status-bar-style" content="black" /> <!-- 忽略識別電話號碼 --> <meta name="format-detection" content="telephone=no" /> <!-- 忽略識別郵箱 --> <meta name="format-detection" content="email=no" /> <!-- 啓用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">
Link設置ios
<!-- icon,-precomposed.png爲後綴的ios7不添加特效 --> <link rel="apple-touch-icon" href="touch-icon-iphone.png"> <!-- 默認大小60*60 --> <link rel="apple-touch-icon" sizes="76x76" href="touch-icon-ipad.png"> <link rel="apple-touch-icon" sizes="120x120" href="touch-icon-iphone-retina.png"> <link rel="apple-touch-icon" sizes="152x152" href="touch-icon-ipad-retina.png"> <!-- apple-touch-startup-image 啓動畫面 --> <link rel="apple-touch-startup-image" href="/startup.png">
<!-- iPhone --> <link href="apple-touch-startup-image-320x460.png" media="(device-width: 320px)" rel="apple-touch-startup-image" /> <!-- iPhone Retina --> <link href="apple-touch-startup-image-640x920.png" media="(device-width: 320px) and (-webkit-device-pixel-ratio: 2)" rel="apple-touch-startup-image" />
<!-- iPhone 5 --> <link rel="apple-touch-startup-image" media="(device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2)" href="apple-touch-startup-image-640x1096.png">
<!-- iPad portrait --> <link href="apple-touch-startup-image-768x1004.png" media="(device-width: 768px) and (orientation: portrait)" rel="apple-touch-startup-image" />
<!-- iPad landscape --> <link href="apple-touch-startup-image-748x1024.png" media="(device-width: 768px) and (orientation: landscape)" rel="apple-touch-startup-image" />
<!-- iPad Retina portrait --> <link href="apple-touch-startup-image-1536x2008.png" media="(device-width: 1536px) and (orientation: portrait) and (-webkit-device-pixel-ratio: 2)" rel="apple-touch-startup-image" />
<!-- iPad Retina landscape --> <link href="apple-touch-startup-image-1496x2048.png"media="(device-width: 1536px) and (orientation: landscape) and (-webkit-device-pixel-ratio: 2)"rel="apple-touch-startup-image" />
電話/短信/Email/Android/GPSweb
<!-- 電話 --> <a href="tel:10086">打電話</a> <a href="wtai://wp/mc;10086">打電話</a> <span onclick="location.href='tel:10086'">打電話</span> <!-- 短信 --> <a href="sms:10086">發短信</a> <a href="sms:10086?body=內容">發短信</a> <a href="sms:10086,10010?body=內容">發短信</a> <!-- Email --> <a href="mailto:a@qq.com">發郵件</a> <a href="mailto:a@qq.com,b@qq.com">發郵件</a> <a href="mailto:a@qq.com?subject=標題">發郵件</a> <a href="mailto:a@qq.com?subject=標題 mailto&cc=b@qq.com">發郵件</a> <!-- 安卓市場--> <a href="market://search?q=MyApp">MyApp</a> <!-- GPS --> <a href="geopoint:經度,緯度">個人位置</a>
樣式設置windows
<!-- 設置開始頁面圖片 --> <link rel=」apple-touch-startup-image」 href=」startup.png」 /> <!-- 在設置書籤的時候能夠顯示好看的圖標 --> <link rel=」apple-touch-icon」 href=」iphon_tetris_icon.png」/> <!-- 肖像模式樣式 --> <link rel="stylesheet" media="all and (orientation:portrait)" href="portrait.css" /> <!-- 風景模式樣式 --> <link rel="stylesheet" media="all and (orientation:landscape)" href="landscape.css" /> <!-- 豎屏時使用的樣式 --> <style media="all and (orientation:portrait)"></style> <!-- 橫屏時使用的樣式 --> <style media="all and (orientation:landscape)"></style>
app是否從主屏啓動api
// IOS if( navigator.standalone === true ){}
關閉IOS鍵盤自動大寫瀏覽器
autocapitalize="off"
IOS禁止彈出菜單(長按a標籤)/複製圖片app
/* IOS */ -webkit-touch-callout: none;
IOS禁止用戶選中文字iphone
/* IOS */ -webkit-user-select: none;
IOS中獲取滾動條距離工具
window.scrollX、window.scrollY
解決盒子邊框溢出字體
-webkit-box-sizing: border-box;
阻止旋轉屏幕時字體大小自動調整
-webkit-text-size-adjust:none;
去除Android裏a標籤邊框
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
設備像素比(設備物理像素/設備獨立像素)
if ( window.devicePixelRatio == 1) {}
去除瀏覽器地址欄
window.onload = function(){ window.setTimeout(scrollTo, 0, 0, 0); };
阻止頁面總體滾動
document.body.addEventListener('touchmove', function(ev) { ev.preventDefault(); }, false);
僞類 :active 生效
// touchstart或touchend document.addEventListener('touchstart',function(){},false);
去除IE10裏input關閉圖標
input:-ms-clear { display:none; }
Date支持placeholder
<input placeholder="Date" type="text" onfocus="(this.type='date')">