Reputation: 35
I'm trying to add a background image in my ion-content here is my current code:
ion-content{
--background: none;
background-image: url('/assets/images/home-background.png');
background-position: center center;
background-repeat: no-repeat;
background-size: cover;
text-align: center;
}
I also tried the following but same thing happened.
ion-content{
--background: url('/assets/images/home-background.png') no-repeat center center / cover;
text-align: center;
}
It is working in browser but when I'm doing ionic cordova run android
, the background image is not showing. I also tried to change the url to url('../assets/images/home-background.png')
, url('./assets/images/home-background.png')
and url('../images/home-background.png')
but it's giving me error.
In this second image, I saw the home-background.png
Upvotes: 1
Views: 2520
Reputation: 11
You can try to change your image url as shown below
ion-content{
--background: none;
background-image: url('../../assets/images/home-background.png');
background-position: center center;
background-repeat: no-repeat;
background-size: cover;
text-align: center;
}
this worked for me.
Upvotes: 0
Reputation: 35
didn't have the chance to solve this problem using the ionic-content, so what I did is to change the ionic-content to div, and it solve my problem. Working in web and android device.
Upvotes: 2
Reputation: 645
background-image: url('..assets/img/home-background.png');
if u have set path just type ../ or ./ automatically path will suggestion
Upvotes: 0
Reputation: 186
Try changing the path keep images in main www/assets/img folder and then set
background-image: url('assets/img/home-background.png');
Upvotes: 0
Reputation: 5075
Open scss file:
ion-content {
background: url('../../assets/img/myBg.jpg') center bottom no-repeat;
background-size: 100%;
}
Upvotes: 0