標籤:
使用iScroll時,input等不能輸入內容的解決方案
<script>function allowFormsInIscroll(){ [].slice.call(document.querySelectorAll(‘input, select, button‘)).forEach(function(el){ el.addEventListener((‘ontouchstart‘ in window)?‘touchstart‘:‘mousedown‘, function(e){ e.stopPropagation(); }) }) } document.addEventListener(‘DOMContentLoaded‘, allowFormsInIscroll, false); </script>
iscroll需要一直監聽使用者的touch操作,以便靈敏的做出對應效果,所以它把其餘的預設事件屏蔽了。
當用iScroll時候,不能使用:focus{outline:0}偽類,否則滑動會卡當 ipad上網頁寬度超過980是,頁面被截斷 content="width=980 預設980;需要重新設定;
<meta name="viewport" content="width=1200, target-densitydpi=high-dpi, user-scalable=no" />
移動端瀏覽器中經常會出現高度100%的渲染錯誤,頁面低端和系統內建的導航條重合了,高度的不正確我們需要重設修正它
document.documentElement.style.height = window.innerHeight + ‘px‘;
疊加區高亮
input, textarea, button, a{-webkit-tap-highlight-color:rgba(0,0,0,0);}
button在ios上的預設樣式 屏蔽輸入框怪異的內陰影。
-webkit-appearance: none;border-radius: 0
IOS 等Retina螢幕 圖片有點朦朧朧的感覺 根據“pixel rotio” 設定圖片大小;
-webkit-background-size可以做高清表徵圖,不過一些低版本的android只能識別background-size
iOS中,當你點擊比如 input 準備輸入時,虛擬鍵盤彈出,整個視窗的 高度 就會變為 減去鍵盤 的高度,加入你在底部有fixed的元素比如btn,這個元素就會跑上來。我是當focus時就把它設:absolute ;在部分android 機型中的輸入框可能多餘的浮出表單,經過觀察與測試發現只有input:password類型的輸入框存在,那麼我們只要使用input:text類型的輸入框並通過樣式-webkit-text-security: disc; 隱藏輸入密碼從而解決。
android 4.0版本以下CSS :active偽狀態效果無法相容,我們給該元素的touch系列的事件(touchstart/touchend/touchmove)綁定一個空匿名方法:
var element=document.getElementsById(”btnShare”);element.addEventListener(‘touchstart’,function(){},false)
移動端還是PC短 如果使用fixed 元素;元素不停渲染問題;這個可以用Google瀏覽器開發人員—esc -esc-rendering-show paint rectangles 查看
-webkit-transform:translateZ(0);
translateZ 還能修複部分 > 字元 問題;
參考網址
http://www.ghugo.com/chrome-rendering-tools-1/ 這個非常好
http://blog.bingo929.com/transform-translate3d-translatez-transition-gpu-hardware-acceleration.html
http://www.w3cfuns.com/article-1248-1.html
移動端 常見問題整理