2016-09-25 160 views
1

使用离子-2时的背景图像被设置和它的尺寸(背景尺寸)被设置为“盖”或“100%100%”,如:IONIC2背景图像的尺寸时

background: url("../../img/bg.jpeg"); 
 
background-repeat: no-repeat; 
 
background-size: cover;

当键盘打开背景图像的尺寸,这可怎么避免? (即使键盘缩小了内容,背景图像的大小保持不变)

+0

喜@Dinana,尽量使固定的背景位置和高度为100%。对我来说,它的工作。 – AishApp

+0

如果你不需要调整BG图片的大小,它可以工作,否则它不会。 – Dinana

回答

0

经过大量的时间搜索没有解决方案后,我决定开发一个使用angular-2的ngStyle,实际上这个解决方案实际上并不重要:

在页面类,创建shouldHeight成员:

export class myPage { 
 
    shouldHeight = document.body.clientHeight + 'px' ; 
 

 
    constructor(private navCtrl: NavController) { 
 
     
 
    } 
 

 
}

然后将其添加到在上述页面中的离子含量:

<ion-content padding [style.background-size]="'100% ' + shouldHeight">

2

用正确的方法嵌入一个全屏幕的背景图像:

ion-content { 
    background: url(images/bg.jpg) no-repeat center center fixed; 
    background-size: cover; 
}