document.body.addEventListener('focusin', (e) => { //软键盘弹起事件
if(e.target.type != 'file'){
//隐藏底部div
// document.getElementById('mybottom').style.display = "none"
}
})
document.body.addEventListener('focusout', () => { //软键盘收起事件
//显示底部div
// document.getElementById('mybottom').style.display = "block"
if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
//软键盘收起的事件处理解决ios收起键盘底部有白色背景
setTimeout(() => {
const scrollHeight = document.documentElement.scrollTop || document.body.scrollTop || 0
window.scrollTo(0, Math.max(scrollHeight - 1, 0))
}, 100)
}
})```
/* 取消ios点击出现黑色背景 */
div{-webkit-tap-highlight-color:rgba(0,0,0,0);}
解决手机端键盘抬起底部fiexd跟着一起抬起,解决ios收起键盘底部有白色背景, 取消ios点击出现黑色背景
最新推荐文章于 2022-10-12 17:56:18 发布