I having problems trying to change the background color in just one IONIC 4 (--type=angular) page. I am trying to add a class for the ion-content. In my html file I Have:
<ion-content class="fondologin"> ... </ion-content>
In my sass I have:
.fondologin{ background-color: #111D12!important; }
The background color is never changed. If I add --ion-background-color:#111D12; in variables.scss the background is successfully changed for every page but I just one to change the color in one page. How can I achieve this?
Styling the Ionic 5 Toolbar ( ion-toolbar ) $toolbar-background: #123456; $toolbar-border-color: #123456; $toolbar-text-color: #123456; $toolbar-active-color: #123456; $toolbar-inactive-color: #123456; Just put them in the variables. scss file and change their values to your desired colors.
The fastest way to change the theme of your Ionic app is to set a new value for primary , since Ionic uses the primary color by default to style most components. Colors can be removed from the map if they aren't being used, but primary should not be removed.
For some reason I solved it this way:
First of all I added --ion-background-color:#ffffff;
in the variables.scss
file inside theme folder.
In my Page scss I wrote:
ion-content{ --ion-background-color:#111D12; }
After that the background was successful set.
I am going to repost the top commented answer , with an extra explanation
ion-content{ --ion-background-color:#111D12; }
Starting from ionic 4, Ionic component implements the concept of shadowDOM, and the old method of finding css selectors in the component that implements shadowDOM no longer works
As such, any modification can only be made if you change the variable that the component references
for example, if ion content references
--ion-background-color: #ffffff
The only way you can modify the background color is by doing this in your css file
ion-content{ --ion-background-color:#111D12; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With