我使用此处提供的示例来设置响应式导航栏
https://theinfogrid.com/tech/developers/angular/responsive-navbar-angular-flex-layout/
我的代码看起来很相似
<div style="height: 85vh;">
<mat-toolbar color="primary" mat-scroll-shrink>
<span>{{title}}</span>
<span class="example-spacer"></span>
<div fxShow="true" fxHide.lt-md="true">
<!-- The following menu items will be hidden on both SM and XS screen sizes -->
<a href="#" mat-button>Home</a>
<a href="#" mat-button>About</a>
<a href="#" mat-button>Services</a>
<a href="#" mat-button>Portfolio</a>
<a href="#" mat-button>Start</a>
<a href="#" mat-button>FAQ</a>
<a href="#" mat-button>Blog</a>
<a href="#" mat-button>Contact</a>
</div>
<div fxShow="true" fxHide.gt-sm="true">
<a href="#" (click)="sidenav.open()">Show Side Menu</a>
</div>
</mat-toolbar>
<mat-sidenav-container fxFlexFill class="example-container">
<mat-sidenav #sidenav fxLayout="column">
<div fxLayout="column">
<a (click)="sidenav.close()" href="#" mat-button>Close</a>
<a href="#" mat-button>Home</a>
<a href="#" mat-button>About</a>
<a href="#" mat-button>Services</a>
<a href="#" mat-button>Portfolio</a>
<a href="#" mat-button>Start</a>
<a href="#" mat-button>FAQ</a>
<a href="#" mat-button>Blog</a>
<a href="#" mat-button>Contact</a>
</div>
</mat-sidenav>
<mat-sidenav-content fxFlexFill>
<p>Demoing some content to make this thing scroll</p>
<p>Demoing some content to make this thing scroll</p>
<p>Demoing some content to make this thing scroll</p>
<p>Demoing some content to make this thing scroll</p>
<p>Demoing some content to make this thing scroll</p>
<p>Demoing some content to make this thing scroll</p>
<p>Demoing some content to make this thing scroll</p>
<p>Demoing some content to make this thing scroll</p>
<p>Demoing some content to make this thing scroll</p>
<p>Demoing some content to make this thing scroll</p>
<p>Demoing some content to make this thing scroll</p>
<p>Demoing some content to make this thing scroll</p>
<p>Demoing some content to make this thing scroll</p>
<p>Demoing some content to make this thing scroll</p>
<p>Demoing some content to make this thing scroll</p>
<p>Demoing some content to make this thing scroll</p>
<p>Demoing some content to make this thing scroll</p>
<p>Demoing some content to make this thing scroll</p>
<p>Demoing some content to make this thing scroll</p>
<p>Demoing some content to make this thing scroll</p>
<p>Demoing some content to make this thing scroll</p>
<p>Demoing some content to make this thing scroll</p>
<p>Demoing some content to make this thing scroll</p>
</mat-sidenav-content>
</mat-sidenav-container>
</div>
我想要发生的是当我向下滚动时让 mat-toolbar 缩小,这在很多网站中都很常见,比如这个:
我不会发布其余的 angular 5 代码,只需按照示例重新创建即可 - 它非常快。
我在这里查看了材料网站
https://material.angular.io/components/toolbar/overview
但是关于如何添加它的解释并不多,而且我对这些东西还很陌生。有谁知道我可以如何自定义它以使工具栏缩小,基于滚动?