1

Using ionic-2 when a background image is set and it's size (background-size) is set to 'cover' or '100% 100%' such as:

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

When the keyboard is opened the background image is resized, how can this be avoided? (So that the background image size remains the same even though the keyboard has shrunk the content)

Dinana
  • 300
  • 3
  • 14

2 Answers2

3

Use the correct way to embed a full screen background image:

ion-content { 
  background: url(images/bg.jpg) no-repeat center center fixed; 
  background-size: cover;
} 
olivier
  • 2,585
  • 6
  • 34
  • 61
0

After a lot of time searching with no solution I decided to develop one using angular-2's ngStyle, and the solution is quite trivial actually:

In the page class, create shouldHeight member:

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

  constructor(private navCtrl: NavController) {
      
  }

}

Then add this to the ion-content in the said page:

<ion-content padding [style.background-size]="'100% ' + shouldHeight">
Dinana
  • 300
  • 3
  • 14