這裏大部分是本身遇到過的狀況,還有一部分借鑑了同行的文章,若是你們有遇到其它坑,歡迎提出來一塊兒研究。css
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" name="viewport" />
<meta content="telephone=no" name="format-detection" />
<meta content="email=no" name="format-detection" />
<meta name="apple-mobile-web-app-capable" content="yes" /><!-- 據說在ios7以上版本就沒效果了 --> <meta name="apple-mobile-web-app-status-bar-style" content="black" /><!-- 可選default、black、black-translucent 可是我都是用black-->
// Javascript: 網頁可見區域寬: document.body.clientWidth 網頁可見區域高: document.body.clientHeight 網頁可見區域寬: document.body.offsetWidth (包括邊線的寬) 網頁可見區域高: document.body.offsetHeight (包括邊線的高) 網頁正文全文寬: document.body.scrollWidth 網頁正文全文高: document.body.scrollHeight 網頁被捲去的高: document.body.scrollTop 網頁被捲去的左: document.body.scrollLeft 網頁正文部分上: window.screenTop 網頁正文部分左: window.screenLeft 屏幕分辨率的高: window.screen.height 屏幕分辨率的寬: window.screen.width 屏幕可用工做區高度: window.screen.availHeight 屏幕可用工做區寬度: window.screen.availWidth // Jquery: $(document).ready(function(){ alert($(window).height()); //瀏覽器當前窗口可視區域高度 alert($(document).height()); //瀏覽器當前窗口文檔的高度 alert($(document.body).height());//瀏覽器當前窗口文檔body的高度 alert($(document.body).outerHeight(true));//瀏覽器當前窗口文檔body的總高度 包括border padding margin alert($(window).width()); //瀏覽器當前窗口可視區域寬度 alert($(document).width());//瀏覽器當前窗口文檔對象寬度 alert($(document.body).width());//瀏覽器當前窗口文檔body的寬度 alert($(document.body).outerWidth(true));//瀏覽器當前窗口文檔body的總寬度 包括border padding margin })
<a href="tel:020-88888888">打電話給:020-88888888</a> <a href="sms:911">發短信給: 911</a>
4.img和backgroundhtml
so,網頁會先加載標籤img的內容,再加載背景圖片background引用的圖片
移動設備上的頁面,當屏幕旋轉的時候會有一個orientationchange事件,能夠給body元素增長此事件的監聽:前端
<body onOrientationchange="updateOrientation();">
進入監聽方法中,經過window。orientation來獲取當前屏幕的狀態:html5
解決方法:jquery
<!-- uc強制豎屏 --> <meta name="screen-orientation" content="portrait"> <!-- QQ強制豎屏 --> <meta name="x5-orientation" content="portrait">
使用事件監聽或事件綁定時,因爲父元素選擇body或document元素,致使在ios中事件觸發無效,因此不使用body和document元素做爲父級元素。android
Date的日期格式,在ios中有兼容性問題,ios的日期會顯示成:NaN;ios
解決方法:在ios中支持"2017/12/26 19:36:00",而不支持"2017-12-26 19:36:00"格式,後面一種格式,在ios中顯示Nan (Android中均可以顯示正常)web
因爲不一樣的手機有不一樣的像素密度,css中的1px並不等於移動設備的1px。項目中使用js和rem作移動端的屏幕適配,因此產生0.5px的狀況,致使低版本的手機展現不了0.5px的邊框。瀏覽器
解決方法:使用css解決1px的問題,而且給須要設置成1px的dom元素直接寫上:border-width:1px;微信
web頁面在PC瀏覽器上瀏覽時有滾動條;可是,在移動端瀏覽器打開時,沒有滾動條
解決方法:將頁面的最外層(我通常在寫頁面時,會在body標籤內寫一個大容器,用於存放頁面的內容)設置overflow:auto/scroll;而且不能設置height屬性的值(height:100%也不行)
列表頁的列表項時(觸摸到文字),在低版本手機中會出現閃退的狀況
解決方法:
js部分:在事件觸發時添加e.preventDefault();,用於阻止默認行爲
css部分:添加禁止文本文本複製的代碼 -webkit-touch-callout: none; user-select: none;
解決方案:在要滾動元素上加上
-webkit-overflow-scrolling: touch; overflow-scrolling: touch;
input,button,textarea{-webkit-appearance: none;}
input:disabled, input[disabled]{ -webkit-opacity:1; opacity: 1; }
css中position: fixed定位會由於其父元素上可能設置了transform屬性而失效。
解決方法:使用url地址後加隨機數來解決
這個問題我有遇到過,而後網上了找了解決方法,可是沒有效果,因此只能改用開始移動播放音樂。