question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ionic v4 Change - Cannot set background-image of ion-content or ion-scroll

See original GitHub issue

Bug Report

Ionic Info

 λ ionic info
cli packages: (C:\Users\julian\AppData\Roaming\npm\node_modules)

   @ionic/cli-utils  : 2.0.0-rc.6
   ionic (Ionic CLI) : 4.0.0-rc.6

global packages:

   cordova (Cordova CLI) : 8.0.0

local packages:

   @angular-devkit/core       : 0.6.0
   @angular-devkit/schematics : 0.6.0
   @angular/cli               : 6.0.1
   @ionic/schematics-angular  : 1.0.0-rc.6
   Cordova Platforms          : none
   Ionic Framework            : @ionic/angular 4.0.0-alpha.7

System:

   NodeJS : v10.2.1
   npm    : 6.1.0
   OS     : Windows 10

Environment Variables:

   ANDROID_HOME : not set

Describe the Bug I cannot use background-image to set the background of the ion-content or ion-scroll.

Steps to Reproduce Steps to reproduce the behavior:

  1. Create new blank App
  2. use scss of the home page (home.page.scss) and add background-image code

Related Code At home.page.scss, none of the following is working

ion-content {
    background-image: url('https://lorempixel.com/400/200/sports/Dummy-Text/');
    background-repeat: no-repeat;
    background-size: 100% 100%;
}

ion-scroll {
    background-image: url('https://lorempixel.com/400/200/sports/Dummy-Text/');
    background-repeat: no-repeat;
    background-size: 100% 100%;
}

ion-content ion-scroll {
    background-image: url('https://lorempixel.com/400/200/sports/Dummy-Text/');
}

But if I add the following at global.scss it will work

app-page-home {
    ion-content ion-scroll {
        background-image: url('https://lorempixel.com/400/200/sports/Dummy-Text/');
    }
}

Expected Behavior I expect to be able to change the background image from the page’s scss file

Additional Context

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
dmastagcommented, May 26, 2018

Thanks, its working as expected.

If the Ionic Team could confirm if this workaround is something that should always be used then I will close this issue.

1reaction
brandyscarneycommented, Sep 24, 2018

I am going to close this since my above comment should resolve all outstanding issues here, and I have recently pushed a fix for #15635 which will be included in the 4.0.0-beta.12 release. If you are still seeing issues, please create a new issue. Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ionic V4 beta 12: can't scale background image in ion-content
I've been unable to scale or otherwise alter a background image when used in an ionic-4 page. In the test.page.scss file, I put...
Read more >
I Cannot set background image in ionic 4 div from template
If your goal is to set background image to the entire page, you could use --background for ion-content . Something like following has...
Read more >
Ionic 4 background image not showing, Ion-img src not working ...
Ionic v4 Change,Ionic v4 Change - Cannot set background-image of ion-content or ion-scroll components as well, e.g. the button element within an ion-button....
Read more >
Ionic 4: How to make a transparent header / toolbar? - Medium
Step 1: Add the fullscreen attribute to ion-content · Step 2: Make the toolbar transparent.
Read more >
Background Images for Ionic 4 | Prototype A - WordPress.com
The background image will either shift or blank out for a moment. ezgif.com-video-to-gif. This is due to the fact that the ion-content component ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found