2015-10-07 67 views
1

我目前正在构建基于Cordova的Web应用程序。Cordova应用程序在iPhone上打开键盘时滚动

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

在下面的示例中,背景应用于html标记,并且徽标位置固定。

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

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

是否有一个基于Web的应用程序科尔多瓦的方式,当键盘打开只有形式移动到顶部,不动的背景下,无论是标志?

我想让键盘缩小视图,将其大小调整为小一点,而不是用右侧的滚动条将其调高。

谢谢。

enter image description here

enter image description here

回答

2

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

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

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

+0

在Android InAppBrowser中很好用,但是我无法在iOS InAppBrowser中使用它。你知道这个设置是否可以在InAppBrowser中工作吗? –

+1

默认情况下,Android对所有Web浏览器都有'KeyboardShrinksView'行为。此插件只会将行为添加到iOS上的主webview。 – connor

相关问题