關鍵代碼javascript
document.getElementById("searchInputbox").addEventListener('touchmove', handler, {passive: false}); function handler() { event.preventDefault(); } var contentBox=document.getElementById("contentBox") contentBox.ontouchstart = function() { document.getElementById("inputForm").blur() }
若是contentBox盒子滾動,則收起鍵盤,避免鍵盤致使fixed定位失效java
源碼地址:https://github.com/zuobaiquan/javascript/tree/master/ios端position爲fixed失效的解決辦法ios
預覽地址:http://zuobaiquan.com/javascript/ios端position爲fixed失效的解決辦法git