简体   繁体   中英

How can I make mat-sidenav take up entire vertical space underneath mat-toolbar?

I'm trying to get the following angular-material layout working. I have a mat-toolbar at the top, and mat-sidenav on the bottom. No matter what I try, I can't get the mat-sidenav-container to take up the whole page height. This is my attempt using grid layout. It looks like it should work, but it doesn't. It seems like the mat-sidenav automatically shrinks to the height of element inside mat-sidenav-content .

在此处输入图像描述

Here's my html:

<div class="main-div">
  <app-header class="app-header"></app-header>
  <app-sidenav class="app-sidenav"></app-sidenav>
</div>

Here's my css:

.main-div {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr;
}

.app-header {
  grid-column: 1 / 2;
  grid-row: 1 / 2;
}

.app-sidenav {
  grid-column: 1 / 2;
  grid-row: 2 / 3;
}

Try adding this

.main-div {
   display: grid;
   grid-template-columns: 1fr;
   grid-template-rows: auto 1fr;
   height: 100vh;
}
.mat-sidenav-container {
   height: 100%;
}
    

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM