2015-10-07 69 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

相關問題