Problem: On iOS, my custom CSS to change the height of the <ion-header-bar> directive to fit a logo doesn’t work. The header seems to return to its default height of 44px and the logo overlaps the content below it.
Left: Screenshot of actual iDevice, logo in <ion-header-bar> overlaps <ion-content>. Right: Screenshot of how it looks in a web browser, in the iOS emulator, and on Android. The logo stays within the <ion-header-bar> element.
Here is the CSS I’m using on the <ion-header-bar> which has the classes of .bar and .bar-header:
Here’s the deal: Ionic applies platform-specific CSS classes on the <ion-header-bar> directive on iOS7. I used the Safari Web Inspector to look at the CSS being applied to the app running on an iDevice, and found the below classes. I modified their values and sure enough my problem was fixed!
/* iOS Specific Overrides to fix logo overlap */
.platform-ios7.platform-cordova:not(.fullscreen) .bar-header:not(.bar-subheader) > * {
margin-top: 25px;
}
.platform-ios7.platform-cordova:not(.fullscreen) .bar-header:not(.bar-subheader) {
height: 90px;
}
.platform-ios7.platform-cordova:not(.fullscreen) .has-header {
top: 90px;
}
This should be documented somewhere, that was one of the most frustrating bugs I’ve ever had to figure out with Ionic. I wish I had thought of the Safari Web Inspector sooner!
To avoid these issues in the future, I would recommend using the Sass feature, and simply change the specific variable to fit your need, in this case, $bar-height.
Hello, i’m trying to override $bar-height only for some specific views with large headers.
Everything that i tried so far doesn’t work.
Any insights on how to override $bar-height for specific view classes or id(s) ?