I currently have a standard layout for my app, toolbar with a fixed sidenav and content section. I have since discovered that I can get the drop shadow on the toolbar with the class inclusion mat-elevation-z4
, however I cannot seem to get the shadow to overlay the content section when I have scrolled down in the section itself.
I have also attempted to use the z-index to correct this...
mat-toolbar
I gave z-index: 2
and <div class="container">
I gave z-index: -1
If somebody could give me some advice, I would be grateful.
The color of a <mat-toolbar> can be changed by using the color property. By default, toolbars use a neutral background color based on the current theme (light or dark). This can be changed to 'primary' , 'accent' , or 'warn' .
The <mat-toolbar> is an Angular Directive used to create a toolbar to show the title, header, or any button action of buttons. <mat-toolbar>: It represents the main container. <mat-toolbar-row>: It adds a new row at the toolbar. Example of ToolBar: ADVERTISEMENT.
the mat-elevation-z8 class is an Angular Material elevation class that allows you to add separation between elements along the z-axis.
The issue is because of the z-index. The toolbar is overshadowed by the content section which affects the box-shadow of toolbar. In order to keep the box-shadow visible, you need to give a higher z-index to toolbar (which you already did). But Z-index works on positioned elements, hence provide position to the .mat-toolbar.
Example:
.mat-toolbar {
position: relative;
}
Predefined CSS classes
The easiest way to add elevation to an element is to simply add one of the predefined CSS classes mat-elevation-z# where # is the elevation number you want, 0-24. Dynamic elevation can be achieved by switching elevation classes:
<div [class.mat-elevation-z2]="!isActive" [class.mat-elevation-z8]="isActive"></div>
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