我如何将Mat-Sidenav的高度设置为100%

发布于 2025-02-02 12:53:00 字数 3510 浏览 2 评论 0原文

我无法向下滚动到底部。我看不到下面的分页。我尝试在Mat-Sidenav-container上使用全屏,但我的Mat-Toolbar丢失了。如何根据我的内容设置Mat-Sidenav-content?您可以看到下图:

”在此处输入图像描述”

furear.component.html

<mat-sidenav-container class="example-container">
  <mat-sidenav mode="side" opened>
      <mat-list class="mt-5">
          <mat-list-item><mat-icon class="me-2">book</mat-icon><a routerLink="/book">Book</a></mat-list-item>
          <mat-divider></mat-divider>
          <mat-list-item><mat-icon class="me-2">supervisor_account</mat-icon><a routerLink="/author">Author</a></mat-list-item>
          <mat-divider></mat-divider>
          <mat-list-item><mat-icon class="me-2">local_offer</mat-icon><a routerLink="/category">Category</a></mat-list-item>
          <mat-divider></mat-divider>
          <mat-list-item><mat-icon class="me-2">folder_shared</mat-icon><a routerLink="/publisher">Publisher</a></mat-list-item>
      </mat-list>
  </mat-sidenav>

  <!-- Main Content -->
  <mat-sidenav-content id="content">
    <mat-card class="header mat-elevation-z5">
      <mat-card-title class="mt-2">Author</mat-card-title>
      <button mat-raised-button color="warn" class="add-button" (click)="openAddModal()">Add new</button>
    </mat-card>
    
    <br>
    
    <div class="example-container float-end">
      <mat-form-field class="example-full-width" appearance="fill">
        <mat-label>Filter</mat-label>
        <input matInput placeholder="Search...">
      </mat-form-field>
    </div>

    <br>
    
    <table mat-table [dataSource]="dataSource" class="mat-elevation-z8">
        <!-- Price Column -->
        <ng-container matColumnDef="authorname">
          <th mat-header-cell *matHeaderCellDef> Author </th>
          <td mat-cell *matCellDef="let element"> {{element.authorname}} </td>
        </ng-container>
    
        <ng-container matColumnDef="actions">
            <th mat-header-cell *matHeaderCellDef> Actions </th>
            <td mat-cell *matCellDef="let element">
              <button mat-raised-button color="primary" (click)="updateClick()">Edit</button>
            </td>
        </ng-container>
      
        <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
        <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
    </table>

    <mat-paginator class="mat-elevation-z5" [pageSize]="10" 
      [pageSizeOptions]="[10, 25, 50, 75, 100]" 
      showFirstLastButtons 
      aria-label="Select page">
    </mat-paginator>

  </mat-sidenav-content>
</mat-sidenav-container>

furear.component.css

#content {
    width: 82%;
    padding: 20px;
    min-height: 100vh;
    transition: all 0.3s;
    background: rgb(240, 237, 237);
}
mat-sidenav-container {
    height: 100%;
}
mat-sidenav {
    width: 18%;
    background-color: #fff;
}
mat-list-item a {
    text-decoration: none;
    color: #000;
}

I can't scroll down my mat-sidenav-content to the bottom. I can't see my pagination down below. I try to use the fullscreen on mat-sidenav-container but my mat-toolbar is missing. How can I set my mat-sidenav-content depending on my content? You can see the image below:

enter image description here

author.component.html

<mat-sidenav-container class="example-container">
  <mat-sidenav mode="side" opened>
      <mat-list class="mt-5">
          <mat-list-item><mat-icon class="me-2">book</mat-icon><a routerLink="/book">Book</a></mat-list-item>
          <mat-divider></mat-divider>
          <mat-list-item><mat-icon class="me-2">supervisor_account</mat-icon><a routerLink="/author">Author</a></mat-list-item>
          <mat-divider></mat-divider>
          <mat-list-item><mat-icon class="me-2">local_offer</mat-icon><a routerLink="/category">Category</a></mat-list-item>
          <mat-divider></mat-divider>
          <mat-list-item><mat-icon class="me-2">folder_shared</mat-icon><a routerLink="/publisher">Publisher</a></mat-list-item>
      </mat-list>
  </mat-sidenav>

  <!-- Main Content -->
  <mat-sidenav-content id="content">
    <mat-card class="header mat-elevation-z5">
      <mat-card-title class="mt-2">Author</mat-card-title>
      <button mat-raised-button color="warn" class="add-button" (click)="openAddModal()">Add new</button>
    </mat-card>
    
    <br>
    
    <div class="example-container float-end">
      <mat-form-field class="example-full-width" appearance="fill">
        <mat-label>Filter</mat-label>
        <input matInput placeholder="Search...">
      </mat-form-field>
    </div>

    <br>
    
    <table mat-table [dataSource]="dataSource" class="mat-elevation-z8">
        <!-- Price Column -->
        <ng-container matColumnDef="authorname">
          <th mat-header-cell *matHeaderCellDef> Author </th>
          <td mat-cell *matCellDef="let element"> {{element.authorname}} </td>
        </ng-container>
    
        <ng-container matColumnDef="actions">
            <th mat-header-cell *matHeaderCellDef> Actions </th>
            <td mat-cell *matCellDef="let element">
              <button mat-raised-button color="primary" (click)="updateClick()">Edit</button>
            </td>
        </ng-container>
      
        <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
        <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
    </table>

    <mat-paginator class="mat-elevation-z5" [pageSize]="10" 
      [pageSizeOptions]="[10, 25, 50, 75, 100]" 
      showFirstLastButtons 
      aria-label="Select page">
    </mat-paginator>

  </mat-sidenav-content>
</mat-sidenav-container>

author.component.css

#content {
    width: 82%;
    padding: 20px;
    min-height: 100vh;
    transition: all 0.3s;
    background: rgb(240, 237, 237);
}
mat-sidenav-container {
    height: 100%;
}
mat-sidenav {
    width: 18%;
    background-color: #fff;
}
mat-list-item a {
    text-decoration: none;
    color: #000;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寄风 2025-02-09 12:53:00

您可以用:

overflow: auto;

You could style your table with:

overflow: auto;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文