当前位置:网站首页>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
边栏推荐
- Tiktok may launch an independent grass planting community platform: will it become the second little red book
- Markdown editor
- Basic knowledge of road loss of 3GPP channel model
- Basic idea of counting and sorting
- Gpt-3 is a peer review online when it has been submitted for its own research
- 组织实战攻防演练的5个阶段
- Ansible overview and module explanation (you just passed today, but yesterday came to your face)
- 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
- A picture to understand! Why did the school teach you coding but still not
- Jetson nano配置pytorch深度学习环境//待完善
猜你喜欢
指针与数组在函数中输入实现逆序输出
offer如何选择该考虑哪些因素
Vscode 如何使用内置浏览器?
装饰器基础学习02
如何设计 API 接口,实现统一格式返回?
Ansible中的inventory主機清單(預祝你我有數不盡的鮮花和浪漫)
Common Oracle SQL statements
树与图的深度优先遍历模版原理
How to design API interface and realize unified format return?
R language principal component PCA, factor analysis, clustering analysis of regional economy analysis of Chongqing Economic Indicators
随机推荐
R language principal component PCA, factor analysis, clustering analysis of regional economy analysis of Chongqing Economic Indicators
Function pointer and pointer function in C language
How to design API interface and realize unified format return?
树与图的深度优先遍历模版原理
Detect when a tab bar item is pressed
How to choose an offer and what factors should be considered
PLC Analog output analog output FB analog2nda (Mitsubishi FX3U)
九章云极DataCanvas公司摘获「第五届数字金融创新大赛」最高荣誉!
Windows are not cheap things
AttributeError: module ‘torch._C‘ has no attribute ‘_cuda_setDevice‘
Read of shell internal value command
Basic knowledge of road loss of 3GPP channel model
Structure actual training camp | after class homework | module 6
九章云极DataCanvas公司蝉联中国机器学习平台市场TOP 3
Station B boss used my world to create convolutional neural network, Lecun forwarding! Burst the liver for 6 months, playing more than one million
谈谈讲清楚这件事的重要性
How to package the parsed Excel data into objects and write this object set into the database?
JS variable
Local tool [Navicat] connects to remote [MySQL] operation
01机器学习相关规定