移动端ios输入框
日常开发中使用input固定定位在底部遇到的一些问题,话不多说上代码 ~~~~(大佬勿喷)
输入框收起时底部留白一大块
let scrollY = null;
$('.animated').focus(function(){
scrollY = $(this).offset().top // 记录获取焦点时页面距离顶部的距离
});
$('.animated').blur(function(){
window.scroll(0, scrollY); //失焦后强制让页面归位
});
输入框获取焦点时会被页面遮盖
$('.animated').focus(function(){
scrollY = $(this).offset().top
// 虚拟键盘挡住input输入框解决方法
setTimeout(function(){
window.scrollTo(0,document.body.clientHeight);
}, 500);
});