我正在使用带有sidenav的angular2-material制作一个新的angular2应用程序.我不能为我的生活得到那个高度为100%的sidenav.我试图让一个菜单滑出来占据屏幕的整个高度.无论用户在哪里滚动,我都希望它以相同的方式打开.
这是我的模板:
<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设置为高度:100%和身体设置为最小高度: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>