iOS 中表单的键盘和滚动问题

Keyboard and scroll problems on forms in iOS

我在 iOS 上遇到了一个非常不寻常的问题 - 在表单样式的屏幕上,当我需要在字段中输入信息时,键盘会弹出,但屏幕不会弹出也不允许滚动,这样就无法看到我正在输入的内容。

在 CSS 中,我在 类:

中使用它
overflow-x: scroll -webkit-overflow-scrolling touch;
overflow: hidden -webkit-transform translate3d (0,0,0);

奇怪的是在Android上是正常的...

为什么会这样?我该怎么办?

iOS 上的键盘以一种非常特殊的方式 运行,这里引用一篇关于该主题的精彩文章The Eccentric Ways of iOS Safari with the Keyboard:

The fundamental problem is that when the soft keyboard appears due to a user tap on a text input box near the bottom of the screen, Safari doesn’t resize the browser window but instead moves it upward such that it is partially offscreen

您可能会阻止 body 向上移动,因此请确保没有会干扰它的代码。