您的位置:首页 > 移动开发

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

2018-02-02 16:26 309 查看
(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 更好的解决方案在这里
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: