当设置了背景图像并且其大小( background - size )设置为'cover‘或'100% 100%’时,使用ionic-2,例如:
background: url("../../img/bg.jpeg");
background-repeat: no-repeat;
background-size: cover;
当键盘打开时,背景图像的大小会被调整,如何避免这种情况?(因此,即使键盘缩小了内容,背景图像的大小也保持不变)
发布于 2017-07-16 19:55:54
使用正确的方式嵌入全屏背景图片:
ion-content {
background: url(images/bg.jpg) no-repeat center center fixed;
background-size: cover;
} 发布于 2016-09-25 09:02:20
在找了很长时间没有解决方案后,我决定使用angular-2的ngStyle开发一个,实际上解决方案非常简单:
在页面类中,创建shouldHeight成员:
export class myPage {
shouldHeight = document.body.clientHeight + 'px' ;
constructor(private navCtrl: NavController) {
}
}
然后将此内容添加到上述页面的ion-content中:
<ion-content padding [style.background-size]="'100% ' + shouldHeight">
https://stackoverflow.com/questions/39682450
复制相似问题