I am trying to get this template style in my Angular app:
----------------------------------------------------
FIXED HEADER
----------------------------------------------------
S |
I |
D |
E |
N | MAIN SCROLLABLE AREA
A |
V |
|
|
|
In this template the header is always visible on the top (fixed) and the main area is scrollable independently from the sidenav.
I know what Angular components I have to use, but I dont know what css styles apply to get the desired result.
I tried the following:
.fixedHeader {
position: fixed;
top: 0;
z-index: 2;
}
With this CSS I obtain the desired result in the fixed header but the rest of the content gets overlaped by the header. If I apply a margin-top to sidenav and main area I can fix this overlapping but playing around with the margin-top px it does not seem to be the right way to do it.
The app code:
In app.component.html I use two custom components:
<mt-toolbar></mt-toolbar>
<mt-sidenav></mt-sidenav>
The mt-toolbar component:
The html
<mat-toolbar class="mat-elevation-z4" color="primary" class="fixedHeader">
TITLE
</mat-toolbar>
The CSS
.fixedHeader {
position: fixed;
top: 0;
z-index: 2;
}
The mt-sidenav component:
The html
<mat-sidenav-container>
<mat-sidenav mode="side" opened disableClose>
<mat-nav-list>
SIDENAV ITEMS
</mat-nav-list>
</mat-sidenav>
<mat-sidenav-content>
## MAIN SCROLLABLE AREA ##
</mat-sidenav-content>
</mat-sidenav-container>