0
我無法想出一種方法來鎖定頂部導航欄以停留在屏幕頂部。當頁面變得太長時,則啓用滾動。我試圖禁止滾動頂部導航欄並將其固定到屏幕頂部。下面Angular 4 - 頂部導航欄不會鎖定在頂部
相關文件列表:
app.component.html
<div class="sidenavContainer" [class.app-dark-theme]="isDarkTheme" [class.app-candy-theme]="isCandyTheme" [class.app-custom-theme]="isCustomTheme">
<md-sidenav-container class="sidenavContainer">
<md-sidenav class="left-nav" id="leftNav" color="primary" #sidenav mode="over">
<md-toolbar layout="row" color="primary">
<h2>
<span>Side Panel</span>
</h2>
<span class="nav-spacer"></span>
<md-button class="close-icon" (click)=sidenav.close()>
<md-icon>close</md-icon>
</md-button>
</md-toolbar>
<nav-menu (onSelected)="setTheme($event)"></nav-menu>
</md-sidenav>
<md-toolbar class="top-nav" color="primary">
<button md-button (click)="sidenav.toggle()">
<md-icon>menu</md-icon>
</button>
<div id="navBarTitle">Dashboard</div>
<span class="nav-spacer"></span>
<div>Signed in as: AdminUser</div>
<md-icon class="nav-icon">
<div routerLink="/settings" mdTooltip="Settings">settings</div>
</md-icon>
<md-icon class="nav-icon" mdTooltip="Help">help</md-icon>
</md-toolbar>
<div class="router-container">
<router-outlet></router-outlet>
</div>
</md-sidenav-container>
</div>
app.component.css
.sidenavContainer {
height: 100%;
width: 100%;
}
/deep/ .mat-sidenav-transition .mat-sidenav-backdrop.mat-sidenav-shown {
background: rgba(0, 0, 0, 0.1);
}
.close-icon {
cursor: pointer;
margin-top: 9px;
}
.top-nav {
position: fixed;
width: 100%;
height: 64px;
top: 0px;
}
.nav-icon {
padding: 0 15px;
cursor: pointer;
}
.router-container {
width: 100%;
position: relative;
top: 64px;
}
出於某種原因位置是:固定;似乎沒有工作。
看看這個問題是否有幫助https://stackoverflow.com/questions/44498363/sticky-toolbar-material-2-and-sidenav/44499866#44499866 – Nehal