html - iOS Safari 放大输入框
问题描述
目前最新的iOS(14.4)仍然会放大任何获得焦点的输入框,除非你在没有焦点的输入上使用16px。
这本身不是问题,但是当从该输入框中移除焦点时 - 缩放仍然存在并破坏了页面的外观。
主单页中的视口标签很好:
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
反应代码:
render() {
return (
<div className='my-form' style={this.props.style}>
<h3>MyForm</h3>
<div>
<input
{...InputGetterSetter(this, 'text')}
placeholder="Please enter text"
onKeyDown={this.onKeyDown.bind(this)} />
</div>
SASS 定义的 css:
.my-form {
width: 100%;
height: 100%;
text-align: center;
@media screen and (-webkit-min-device-pixel-ratio:0) {
select,
textarea,
input {
font-size: 16px;
}
}
input {
width: 66%;
text-align: center;
}
.bottom-button {
background-color: #00ac69;
position: absolute;
bottom: 0;
left: 0;
right: 0;
width: 100%;
height: 150px;
outline: none;
border: none;
overflow: hidden;
}
}
.keyboard-expanded {
.my-form {
.bottom-button {
height: 60px;
.ion-ios-telephone {
font-size: 22pt;
}
}
}
}
.dark {
.my-form {
input {
color: white;
}
}
}
可以通过设置字体大小来防止缩放,但是如果我们想要缩放但只是为了取消缩放呢?这可能吗?
解决方案
还像这样添加元标记user-scalable=no
:
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, user-scalable=no">
推荐阅读
- algorithm - 大量顶点的旅行商问题
- reactjs - 大开关/外壳功能或多个独立功能
- python - 根据日期范围中的 DateTimeIndex 更新列
- java - Apache Flink Job 集群 rpc.address 绑定到 kubernetes 上的 localhost
- wordpress - WooCommerce 本地取货加挂
- java - 比较POST请求的参数
- ios - AVPlayer 播放断断续续,仅在使用 AVMutableComposition 时出现不良网络行为
- kotlin - Kotlin 中的属性观察器(向 ArrayList 添加元素时)
- permissions - Wix 自定义操作和刻录引导程序的权限问题
- html - 我想添加背景图片