I just created a blank project with ionic 5 and added a background image for the content. After that i modified the page.page.scss file to make the header transparent but it didn't work.
If i just pick a background color for the ion-content, that works.
Please help me.
Here is my environment :
Ionic:
Ionic CLI : 6.11.0 (/usr/local/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/angular 5.3.1
@angular-devkit/build-angular : 0.901.12
@angular-devkit/schematics : 9.1.12
@angular/cli : 9.1.12
@ionic/angular-toolkit : 2.3.0
Capacitor:
Capacitor CLI : 2.4.0
@capacitor/core : 2.4.0
Utility:
cordova-res : not installed
native-run : not installed
System:
NodeJS : v14.7.0 (/usr/local/bin/node)
npm : 6.14.7
OS : macOS Catalina
Here is the page SCSS code :
// ion-content {--background: #f1453d !important;
// --color : #f1453d !important }
ion-content {
--background : none;
border:none;
background-image: url(../../assets/imgs/bckgrnd.jpg) ;
background-repeat: no-repeat;
background-attachment: scroll;
background-size:cover;
background-position:center bottom;
}
ion-toolbar {
--background: transparent !important;
--ion-color-base: transparent !important;
--border-color: transparent;
--background-color: transparent !important;
}
}
HTML code :
<ion-header [translucent]="true">
<ion-toolbar>
<ion-title>
Blank
</ion-title>
</ion-toolbar>
</ion-header>
<ion-content [fullscreen]="true">
<div id="container">
<strong>Ready to create an app?</strong>
<p>Start with Ionic <a target="_blank" rel="noopener noreferrer" href="https://ionicframework.com/docs/components">UI Components</a></p>
</div>
</ion-content>
And the result in image :
header white but not transparent...
So if someone has already had this issue or the solution, it would save me and my app from many many troubles.
thank you Bye
This is a very simple "one-liner" CSS solution to add a transparent (background) image to ionic 4+ content element without having troubles with transparent child elements, like text.