关键代码
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定位失效
源码地址:https://github.com/zuobaiquan/javascript/tree/master/ios端position为fixed失效的解决办法
预览地址:http://zuobaiquan.com/javascript/ios端position为fixed失效的解决办法