Wrapping the toolbar and the other content in a CSS grid - having 100% height - will work, making both a grid row where the toolbar has auto height and the other content has overflow:auto.
<div class="container">
<mat-toolbar>
<h1>
Fixed Angular Material toolbar
</h1>
</mat-toolbar>
<main>
<p>
This is the main content which is scrollable because the main content has 'overflow-y: auto' and is a grid row
with a height of 1fr (the container is a CSS grid). This only works when the container div has a height of 100%.
</p>
</main>
</div>
.container {
height: 100%;
display: grid;
grid-template-rows: auto 1fr; // mat-toolbar main
}
/* Grid row 1 */
mat-toolbar {
}
/* Grid row 2 */
main {
overflow-y: auto;
padding: 1rem;
}
Here is a working example: https://www.jitblox.com/design/MdTqMjv9Pr
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…