Angular Flex布局始终显示滚动条

时间:2019-03-09 21:27:38

标签: css angular flexbox angular-flex-layout

我对角度和弹性布局不熟悉。我的页面非常简单。带侧面导航栏和路由器出口的接头。

我遇到了我的页面始终显示滚动条的问题。

如果我删除fxFlexFill,则滚动条不会显示。我该如何解决?

这是stackblitz演示Stackblitz

这是我的模板:

.fill-space {
  flex: 1 1 auto;
}

.content {
  flex: 1 1 auto;
  padding: 15px;
  position: relative;
  overflow-y: auto;
}

.footer {
  display: flex;
  flex: 1 0 auto;
  justify-content: center;
}
<div style="height: 100vh;">
  <mat-toolbar color="primary" class="fixed-header">
    <mat-toolbar-row>
      <button mat-icon-button (click)="sidenav.toggle()" fxShow="true" fxHide.gt-sm>
        <mat-icon>menu</mat-icon>
      </button>
      <span><button mat-button routerLink="/home"><h3>HOSPITALITY</h3></button></span>
      <span class="fill-space"></span>
      <div fxShow="true" fxHide.lt-md="true">
        <button mat-button routerLink="/home">HOME</button>
        <button mat-button routerLink="/account">MY ACCOUNT</button>
        <button mat-button routerLink="/login">LOGOUT</button>

        <a href="#" routerLink="/cart" mat-button>
          <mat-icon>shopping_cart</mat-icon>
          0
        </a>
      </div>
    </mat-toolbar-row>
  </mat-toolbar>

  <mat-sidenav-container fxFlexFill>
    <mat-sidenav #sidenav fxLayout="column" mode="over"  opened="false" fxHide.gt-sm="true">
      
      <div fxLayout="column">
        <button mat-button routerLink="/home">HOME</button>
        <button mat-button routerLink="/account">MY ACCOUNT</button>
        <button mat-button routerLink="/login">LOGOUT</button>

        <a href="#" routerLink="/cart" mat-button>
          <mat-icon>shopping_cart</mat-icon>
          0
        </a>
      <a (click)="sidenav.toggle()" mat-list-item>
        <mat-icon>close</mat-icon> Close
      </a>
      </div>
    </mat-sidenav>
    <mat-sidenav-content >
      <div class="content">
        <router-outlet></router-outlet>
      </div>
    </mat-sidenav-content>
  </mat-sidenav-container>

</div>

0 个答案:

没有答案