我正在使用带有sidenav的angular2材料制作一个新的angular2应用程序.我不能为了我的生活,使得sidenav的高度是100%.我正在尝试一个菜单来滑出,占据屏幕的整个高度.而且我希望它以相同的方式打开,无论用户滚动的位置.
这是我的模板:
<md-sidenav-layout class="demo-sidenav-layout"> <md-sidenav #start mode="over"> <a [routerLink]="['/login']" class="btn btn-primary">Log in</a> <br> </md-sidenav> <md-toolbar color="primary"> <button md-button (click)="start.toggle()">Open Side Drawer</button> <span>Spellbook</span> <span class="demo-fill-remaining"> </span> </md-toolbar> <div class="demo-sidenav-content"> <router-outlet></router-outlet> </div> </md-sidenav-layout>
这里是我的CSS:
.demo-sidenav-layout { //border: 3px solid black; min-height:100%; md-sidenav { padding: 10px; background: gainsboro; min-height: 100%; } } .demo-sidenav-content { padding: 15px; min-height:100%; } .demo-toolbar { padding: 6px; .demo-toolbar-icon { padding: 0 14px 0 14px; } .demo-fill-remaining { flex: 1 1 auto; } }
我也有html设置为height:100%,body设置为min-height:100%
解决方法
使用全屏
<md-sidenav-layout fullscreen> <md-sidenav #start mode="over"> <a [routerLink]="['/login']" class="btn btn-primary">Log in</a> <br> </md-sidenav> <md-toolbar color="primary"> <button md-button (click)="start.toggle()">Open Side Drawer</button> <span>Spellbook</span> <span class="demo-fill-remaining"></span> </md-toolbar> <div class="demo-sidenav-content"> <router-outlet></router-outlet> </div> </md-sidenav-layout>