当前位置:网站首页>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
边栏推荐
- File upload vulnerability summary
- Camera calibration (I): robot hand eye calibration
- Programmers go to work fishing, so play high-end!
- Decorator basic learning 02
- 01机器学习相关规定
- Stm32f103ze+sht30 detection of ambient temperature and humidity (IIC simulation sequence)
- [practice leads to truth] is the introduction of import and require really the same as what is said on the Internet
- Meaning of 'n:m' and '1:n' in database design
- When knative meets webassembly
- JS variable case output user name
猜你喜欢

Decorator basic learning 02

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

Error: No named parameter with the name ‘foregroundColor‘

树与图的深度优先遍历模版原理

Basic knowledge of road loss of 3GPP channel model

Programmers go to work fishing, so play high-end!

DFS和BFS概念及实践+acwing 842 排列数字(dfs) +acwing 844. 走迷宫(bfs)

Time complexity & space complexity
![[line segment tree practice] recent requests + area and retrieval - array modifiable + my schedule I / III](/img/13/d598bb53b71fbadd4a97c603152124.png)
[line segment tree practice] recent requests + area and retrieval - array modifiable + my schedule I / III

JS also exports Excel
随机推荐
Talk about the importance of making it clear
动态生成表格
System framework of PureMVC
Tree map: tree view - draw covid-19 array diagram
Can I specify a path in an attribute to map a property in my class to a child property in my JSON?
JS variable case output user name
深入解析Kubebuilder
mpf2_ Linear programming_ CAPM_ sharpe_ Arbitrage Pricin_ Inversion Gauss Jordan_ Statsmodel_ Pulp_ pLU_ Cholesky_ QR_ Jacobi
STM32 system timer flashing LED
npm ERR! 400 Bad Request - PUT xxx - “devDependencies“ dep “xx“ is not a valid dependency name
A row of code r shows the table of Cox regression model
R语言主成分pca、因子分析、聚类对地区经济研究分析重庆市经济指标
3.基金的类型
2.证券投资基金的概述
Read of shell internal value command
JS variable case
九章云极DataCanvas公司获评36氪「最受投资人关注的硬核科技企业」
树与图的深度优先遍历模版原理
jvm是什么?jvm调优有哪些目的?
A detailed explanation of head pose estimation [collect good articles]