IONIC2背景图像在键盘打开时调整大小

时间:2016-09-25 01:02:20

标签: android css background keyboard ionic2

在设置背景图片时使用ionic-2,并将其大小(背景大小)设置为'覆盖'或者' 100%100%'如:



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




当键盘打开时,背景图像会调整大小,如何避免这种情况? (因此即使键盘缩小了内容,背景图像大小也保持不变)

2 个答案:

答案 0 :(得分:2)

使用正确的方法嵌入全屏背景图像:

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

答案 1 :(得分: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">
&#13;
&#13;
&#13;

相关问题