【问题标题】:Cordova application scrolls when keyboard is open on iPhone在 iPhone 上打开键盘时 Cordova 应用程序滚动
【发布时间】:2015-10-07 16:19:56
【问题描述】:

我目前正在构建一个基于 Cordova 的 Web 应用程序。

当用户决定关注文本框并且键盘打开时,整个应用程序正在向上滚动,包括背景和所有固定元素。

在下面的例子中,背景是应用在 html 标签上的,并且 logo 是固定位置的。

html {
    background: url('background.jpg') center center;
    background-size: cover;
    height: 100vh;
    overflow: hidden;
}

.logo {
    top: 80px;
    position: fixed;
    text-align: center;
}

有没有办法使用基于网络的科尔多瓦应用程序,当键盘打开时只将表单移动到顶部,而不移动背景,也不移动徽标?

我希望键盘缩小视图,将其调整为更小的尺寸,而不是使用右侧的滚动条将其向上推。

谢谢。

【问题讨论】:

    标签: html ios css cordova


    【解决方案1】:

    您可以为此使用keyboard plugin。安装插件,然后在 config.xml 文件中设置此首选项。

    <preference name="KeyboardShrinksView" value="true" /> 
    

    它通过将 webview 缩小到键盘上方的空间来工作,所以这应该会给你描述的行为。

    【讨论】:

    • 在 Android InAppBrowser 中运行良好,但我无法在 iOS InAppBrowser 中运行。你知道这些设置是否应该在 InAppBrowser 中起作用吗?
    • Android 默认情况下对所有 webview 都具有 KeyboardShrinksView 行为。此插件仅将行为添加到 iOS 上的主 webview。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-08
    • 2020-12-06
    • 2016-12-17
    • 2022-10-09
    • 2017-08-06
    • 2020-08-21
    相关资源
    最近更新 更多