当前位置:网站首页>app内嵌h5---iphone软键盘遮挡输入文字
app内嵌h5---iphone软键盘遮挡输入文字
2022-07-06 22:39:00 【Kratial】
1.产生问题的原因
在ios中,软键盘在页面最上层,软键盘的弹起不会引起窗口高度的变化,故而会遮挡原本处于最底部的输入框。
但是在android下,软键盘与窗口处于同一层,所以当软键盘弹起时,当前窗口会发生变化,故而不存在这个问题。
2.如何监听软键盘的弹出和隐藏
在ios中聚焦的时候软键盘会弹起,失去焦点的时候软键盘会收起
3.解决方案
(1)scrollIntoView
(2)监听聚焦和失焦的情况
(3)使用这个scrollIntoView,需保证当前输入框在原本的可视区域外
handleFocus(elem) {
console.log('软键盘弹起')
document.body.style.height = '100vh' + 软键盘高度
document.querySelector('.' + elem).scrollIntoView();
}
},
handleBlur() {
document.body.style.height = '100%'
console.log('软键盘隐藏')
}
4.关于scrollIntoView的介绍
Element 接口的 scrollIntoView() 方法会滚动元素的父容器,使被调用 scrollIntoView() 的元素对用户可见。
参考链接:MDN—scrollIntoView
边栏推荐
- 01 machine learning related regulations
- [digital analog] source code of MATLAB allcycles() function (not available before 2021a)
- Lessons and thoughts of the first SQL injection
- [line segment tree practice] recent requests + area and retrieval - array modifiable + my schedule I / III
- [practice leads to truth] is the introduction of import and require really the same as what is said on the Internet
- C语言中函数指针与指针函数
- [Android kotlin collaboration] use coroutinecontext to realize the retry logic after a network request fails
- JDBC link Oracle reference code
- Time complexity & space complexity
- U++ 游戏类 学习笔记
猜你喜欢
U++ 游戏类 学习笔记
当 Knative 遇见 WebAssembly
Decorator basic learning 02
[practice leads to truth] is the introduction of import and require really the same as what is said on the Internet
九章云极DataCanvas公司蝉联中国机器学习平台市场TOP 3
Vscode automatically adds a semicolon and jumps to the next line
深入解析Kubebuilder
JDBC link Oracle reference code
指针与数组在函数中输入实现逆序输出
Gavin teacher's perception of transformer live class - rasa project actual combat e-commerce retail customer service intelligent business dialogue robot microservice code analysis and dialogue experim
随机推荐
Leetcode notes
Can I specify a path in an attribute to map a property in my class to a child property in my JSON?
A picture to understand! Why did the school teach you coding but still not
acwing 843. N-queen problem
DFS和BFS概念及实践+acwing 842 排列数字(dfs) +acwing 844. 走迷宫(bfs)
U++ 游戏类 学习笔记
National meteorological data / rainfall distribution data / solar radiation data /npp net primary productivity data / vegetation coverage data
Talk about the importance of making it clear
npm ERR! 400 Bad Request - PUT xxx - “devDependencies“ dep “xx“ is not a valid dependency name
深入解析Kubebuilder
3.基金的类型
A row of code r shows the table of Cox regression model
Ansible overview and module explanation (you just passed today, but yesterday came to your face)
Wechat can play the trumpet. Pinduoduo was found guilty of infringement. The shipment of byte VR equipment ranks second in the world. Today, more big news is here
Two divs are on the same line, and the two divs do not wrap "recommended collection"
Pointer and array are input in function to realize reverse order output
程序员上班摸鱼,这么玩才高端!
offer如何选择该考虑哪些因素
STM32F103 realize IAP online upgrade application
STM32F103ZE+SHT30检测环境温度与湿度(IIC模拟时序)