唤起小米安全键盘,输入密码等,然后收起安全键盘;底部出现空白;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<style>
.page {
overflow: auto;
height: 100vh;
}
p {
height: 120px;
display: flex;
justify-content: center;
}
.container {
padding: 32px;
}
input {
width: calc(100% - 20px);
margin-top: 20px;
padding: 10px;
}
.tip {
padding: 32px;
}
</style>
<body>
<div class="page">
<p>测试</p>
<div style="text-align: center">ttttttttt</div>
<div class="container">
<input type="number" placeholder="请输入手机号码" />
<input type="password" placeholder="请输入密码" id="passwordInput" />
</div>
<div class="tip">
<span>测试内容测试内容测试内容测试内容测试内容测试内容测试内容测试内容</span>
</div>
<div class="tip">
<span>22222222222222222222</span>
</div>
</div>
</body>
<script src="https://cdn.bootcdn.net/ajax/libs/vConsole/3.3.4/vconsole.min.js"></script>
<script>
new VConsole();
console.warn(window.innerHeight);
var passwordInput = document.getElementById("passwordInput");
passwordInput.addEventListener("blur", handleInputBlur);
function handleInputBlur() {
setTimeout(() => {
window.scrollTo(0, 0);
passwordInput.scrollIntoView();
}, 300);
}
</script>
</html>
请问这个问题得到了解决吗?
思路二:监听键盘收起事件,屏幕滚动事件等,比较麻烦。