解决ios系统里 input/textarea/contenteditable 固定底部,点击输入框键盘被覆盖统一解决方案:(亲测)
针对ios系统兼容
1.version < ios11:利用原生的scrollIntoView()&&scrollIntoViewIfNeeded();
$('input').focus(function(){
settimeout(()=>{
$('input')[0].scrollIntoView();
$('input')[0].scrollIntoViewIfNeeded();
}, 500)
})
2.ios11.0 <= version < ios12:利用定位方法以及原生方法
$('input').focus(function(){
$('input').css({'position':'absolute'});
setTimeout(function(){
$('input')[0].scrollIntoView();
$('input')[0].scrollIntoViewIfNeeded();
},500);
})
$('input').blur(function(){
$('input').css({'position':'fixed'});
})
3.>= ios12:系统兼容得很好,只需要处理好微信input失焦后会卡顿需要模拟点击页面才会还原。
$('input').blur(function(){
if(weixin()){
let scrollTop = document.body.scrollTop;
window.scroll(0 ,scrollTop);
}
})
iOS输入框键盘问题全攻略:固定底部及兼容性解决方案
本文详细介绍了解决iOS系统中input、textarea和contenteditable元素在键盘弹出时被覆盖的三种有效方法,包括针对不同版本的iOS系统采用scrollIntoView、定位及微信输入框处理技巧。确保了跨版本的兼容性和用户体验。
6257

被折叠的 条评论
为什么被折叠?



