简体   繁体   English

Angular Material Design:使用顶部导航栏和左侧导航栏构建模板

[英]Angular Material Design: build template with top navbar and left sidenav

Hi i want build a simple template using Angular Material 2: 嗨,我想使用Angular Material 2构建一个简单的模板:

在此处输入图片说明

this is the code 这是代码

<md-toolbar>
    <button><md-icon>menu</md-icon></button>
    <h1>Angular</h1>
</md-toolbar>

<md-sidenav-container>

  <md-sidenav>
  <nav>
    <ul>
      <li><a routerLink="/Foo" routerLinkActive="active">Foo</a></li>
      <li><a routerLink="/Bar" routerLinkActive="active">Bar</a></li>
      <li><a routerLink="/Baz" routerLinkActive="active">Bar</a></li>
    </ul>
  </nav>
  </md-sidenav>

  <router-outlet></router-outlet>

  <footer></footer>

</md-sidenav-container>

i have a bit of problem: 我有一些问题:

  1. the sidenav cover the router-outlet sidenav盖上路由器插座
  2. the router-outlet isn't 100% height 路由器插座的高度不是100%

it's possible achieve this template only using material components (without css hack)? 是否有可能仅使用材料组件来实现此模板(不使用CSS hack)?

Here's a close sample of your template. 这是您模板的详细示例。 I just added color to easily distinguish them. 我只是添加颜色以轻松区分它们。

<md-toolbar color="accent">
    <button (click)="sidenav.toggle()">
      <md-icon>menu</md-icon>
    </button>
    <h1>Angular</h1>
</md-toolbar>

<md-sidenav-container style="height: 91vh;background: yellow">

  <md-sidenav #sidenav mode="side" style="background: orange">
    Sidenav!
  </md-sidenav>

  <md-tab-group>
    <md-tab label="Tab 1">Content 1</md-tab>
    <md-tab label="Tab 2">Content 2</md-tab>
 </md-tab-group>

</md-sidenav-container>

<footer style="background: skyblue">This is footer</footer>

demo 演示

Hope this helps! 希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM