溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶(hù)服務(wù)條款》

解決鍵盤(pán)彈出時(shí),webview被擠壓導(dǎo)致背景圖片被擠壓出空白

發(fā)布時(shí)間:2020-07-13 04:11:58 來(lái)源:網(wǎng)絡(luò) 閱讀:1820 作者:1503849 欄目:開(kāi)發(fā)技術(shù)

第一種方法:

1、給外層div容器設(shè)置背景圖片

2、監(jiān)聽(tīng)鍵盤(pán)彈出事件,彈出時(shí)調(diào)整容器的高度以適應(yīng)背景圖片

<body onresize="windowSizeChange();">

var oglHeight = document.querySelector("body").offsetHeight;

var windowSizeChange = function() { //彈出鍵盤(pán)時(shí)調(diào)整頁(yè)面的高度,防止背景圖片被擠壓出空白區(qū)域

var tempHeight = document.querySelector("body").offsetHeight;

if(tempHeight == oglHeight) {

console.info("屏幕鍵盤(pán)隱藏");

document.getElementById('content').style.height = "100%";

} else {

console.info("鍵盤(pán)顯示");

document.getElementById('content').style.height = "390px";

}

};


第二種方法:

背景固定,使用:before

body:before {

content: "";

position: fixed;

z-index: -1;

top: 0;

right: 0;

bottom: 0;

left: 0;

background: url(../../p_w_picpaths/10.jpg) center 0 no-repeat;

background-size: cover;

}


向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI