使用離子-2時的背景圖像被設置和它的尺寸(背景尺寸)被設置爲「蓋」或「100%100%」,如:IONIC2背景圖像的尺寸時
background: url("../../img/bg.jpeg");
background-repeat: no-repeat;
background-size: cover;
當鍵盤打開背景圖像的尺寸,這可怎麼避免? (即使鍵盤縮小了內容,背景圖像的大小保持不變)
使用離子-2時的背景圖像被設置和它的尺寸(背景尺寸)被設置爲「蓋」或「100%100%」,如:IONIC2背景圖像的尺寸時
background: url("../../img/bg.jpeg");
background-repeat: no-repeat;
background-size: cover;
當鍵盤打開背景圖像的尺寸,這可怎麼避免? (即使鍵盤縮小了內容,背景圖像的大小保持不變)
經過大量的時間搜索沒有解決方案後,我決定開發一個使用angular-2的ngStyle,實際上這個解決方案實際上並不重要:
在頁面類,創建shouldHeight成員:
export class myPage {
shouldHeight = document.body.clientHeight + 'px' ;
constructor(private navCtrl: NavController) {
}
}
然後將其添加到在上述頁面中的離子含量:
<ion-content padding [style.background-size]="'100% ' + shouldHeight">
用正確的方法嵌入一個全屏幕的背景圖像:
ion-content {
background: url(images/bg.jpg) no-repeat center center fixed;
background-size: cover;
}
喜@Dinana,儘量使固定的背景位置和高度爲100%。對我來說,它的工作。 – AishApp
如果你不需要調整BG圖片的大小,它可以工作,否則它不會。 – Dinana