移动端,input输入获得焦点被键盘遮住简单解决方案

(function (window,document) {
document.querySelector('input[type="text"]').addEventListener('focus',function (e) {
setTimeout(function () {
var docHeight = window.innerHeight;
var bottom = e.target.getBoundingClientRect().bottom
var scrollHeight = bottom-docHeight
if(scrollHeight>0){
document.body.scrollTop = scrollHeight+document.body.scrollTop+10
}
},400)
},false)
})(window,document)


//可以解决部分代码的

  

http://www.cnblogs.com/jiebba/p/8405772.html    更好的解决方案在这里

posted @ 2018-02-02 16:26  小结巴巴吧  阅读(1032)  评论(0编辑  收藏  举报