iamjc015
iamjc015

Reputation: 2245

Adding image background on IONIC 2 Component

I wanted to add image as background in one of my components. I'm not really sure how to actually locate my image file. I put it inside src/assets/images folder.

This is my scss for the component:

page-login {
  body {
      background-image: url(assets/images/cool.jpg);
      background-size: cover;
      background-repeat: no-repeat;
      background-position: center center;
  }
}

Nothing seems happening.

What should I do?

Thanks!

Upvotes: 0

Views: 77

Answers (1)

amin arghavani
amin arghavani

Reputation: 1883

Use this code:

page-login{
   ion-content {
      background-image: url('../assets/images/cool.jpg')!important;
      background-size: cover;
   }
}

I assumed your page is in src/pages/page1/page-login.scss.

Upvotes: 1

Related Questions