Layout布局

协助进行页面级整体布局。

设计规则

尺寸

一级导航项偏左靠近 logo 放置,辅助菜单偏右放置。

  • 顶部导航(大部分系统):一级导航高度 64px,二级导航 48px
  • 顶部导航(展示类页面):一级导航高度 80px,二级导航 56px
  • 顶部导航高度的范围计算公式为:48+8n
  • 侧边导航宽度的范围计算公式:200+8n

交互

  • 一级导航和末级的导航需要在可视化的层面被强调出来;
  • 当前项应该在呈现上优先级最高;
  • 当导航收起的时候,当前项的样式自动赋予给它的上一个层级;
  • 左侧导航栏的收放交互同时支持手风琴和全展开的样式,根据业务的要求进行适当的选择。

视觉

导航样式上需要根据信息层级合理的选择样式:

  • 大色块强调

建议用于底色为深色系时,当前页面父级的导航项。

  • 高亮火柴棍

当导航栏底色为浅色系时使用,可用于当前页面对应导航项,建议尽量在导航路径的最终项使用。

  • 字体高亮变色

从可视化层面,字体高亮的视觉强化力度低于大色块,通常在当前项的上一级使用。

  • 字体放大

12px14px 是导航的标准字号,14 号字体用在一、二级导航中。字号可以考虑导航项的等级做相应选择。

组件概述

  • nz-layout:布局容器,其下可嵌套 nz-headernz-sidernz-contentnz-footernz-layout 本身,可以放在任何父容器中。
  • nz-header:顶部布局,自带默认样式,其下可嵌套任何元素,只能放在 nz-layout 中。
  • nz-sider:侧边栏,自带默认样式及基本功能,其下可嵌套任何元素,只能放在 nz-layout 中。
  • nz-content:内容部分,自带默认样式,其下可嵌套任何元素,只能放在 nz-layout 中。
  • nz-footer:底部布局,自带默认样式,其下可嵌套任何元素,只能放在 nz-layout 中。

注意:采用 flex 布局实现,请注意浏览器兼容性问题。

代码演示

Layout布局 - 图1

基本结构

典型的页面布局。

  1. import { Component } from '@angular/core';
  2. @Component({
  3. selector: 'nz-demo-layout-basic',
  4. template: `
  5. <nz-layout>
  6. <nz-header>Header</nz-header>
  7. <nz-content>Content</nz-content>
  8. <nz-footer>Footer</nz-footer>
  9. </nz-layout>
  10. <nz-layout>
  11. <nz-header>Header</nz-header>
  12. <nz-layout>
  13. <nz-sider>Sider</nz-sider>
  14. <nz-content>Content</nz-content>
  15. </nz-layout>
  16. <nz-footer>Footer</nz-footer>
  17. </nz-layout>
  18. <nz-layout>
  19. <nz-header>Header</nz-header>
  20. <nz-layout>
  21. <nz-content>Content</nz-content>
  22. <nz-sider>Sider</nz-sider>
  23. </nz-layout>
  24. <nz-footer>Footer</nz-footer>
  25. </nz-layout>
  26. <nz-layout>
  27. <nz-sider>Sider</nz-sider>
  28. <nz-layout>
  29. <nz-header>Header</nz-header>
  30. <nz-content>Content</nz-content>
  31. <nz-footer>Footer</nz-footer>
  32. </nz-layout>
  33. </nz-layout>
  34. `,
  35. styles: [
  36. `
  37. :host {
  38. text-align: center;
  39. }
  40. nz-header,
  41. nz-footer {
  42. background: #7dbcea;
  43. color: #fff;
  44. }
  45. nz-footer {
  46. line-height: 1.5;
  47. }
  48. nz-sider {
  49. background: #3ba0e9;
  50. color: #fff;
  51. line-height: 120px;
  52. }
  53. nz-content {
  54. background: rgba(16, 142, 233, 1);
  55. color: #fff;
  56. min-height: 120px;
  57. line-height: 120px;
  58. }
  59. nz-layout {
  60. margin-bottom: 48px;
  61. }
  62. nz-layout:last-child {
  63. margin: 0;
  64. }
  65. `
  66. ]
  67. })
  68. export class NzDemoLayoutBasicComponent {}

Layout布局 - 图2

上中下布局

最基本的『上-中-下』布局。

一般主导航放置于页面的顶端,从左自右依次为:logo、一级导航项、辅助菜单(用户、设置、通知等)。通常将内容放在固定尺寸(例如:1200px)内,整个页面排版稳定,不受用户终端显示器影响;上下级的结构符合用户上下浏览的习惯,也是较为经典的网站导航模式。页面上下切分的方式提高了主工作区域的信息展示效率,但在纵向空间上会有一些牺牲。此外,由于导航栏水平空间的限制,不适合那些一级导航项很多的信息结构。

  1. import { Component } from '@angular/core';
  2. @Component({
  3. selector: 'nz-demo-layout-top',
  4. template: `
  5. <nz-layout class="layout">
  6. <nz-header>
  7. <div class="logo"></div>
  8. <ul nz-menu [nzTheme]="'dark'" [nzMode]="'horizontal'" style="line-height: 64px;">
  9. <li nz-menu-item>nav 1</li>
  10. <li nz-menu-item>nav 2</li>
  11. <li nz-menu-item>nav 3</li>
  12. </ul>
  13. </nz-header>
  14. <nz-content style="padding:0 50px;">
  15. <nz-breadcrumb style="margin:16px 0;">
  16. <nz-breadcrumb-item>Home</nz-breadcrumb-item>
  17. <nz-breadcrumb-item>List</nz-breadcrumb-item>
  18. <nz-breadcrumb-item>App</nz-breadcrumb-item>
  19. </nz-breadcrumb>
  20. <div style="background:#fff; padding: 24px; min-height: 280px;">Content</div>
  21. </nz-content>
  22. <nz-footer style="text-align: center;">Ant Design ©2019 Implement By Angular</nz-footer>
  23. </nz-layout>
  24. `,
  25. styles: [
  26. `
  27. .logo {
  28. width: 120px;
  29. height: 31px;
  30. background: rgba(255, 255, 255, 0.2);
  31. margin: 16px 24px 16px 0;
  32. float: left;
  33. }
  34. `
  35. ]
  36. })
  37. export class NzDemoLayoutTopComponent {}

Layout布局 - 图3

顶部-侧边布局-通栏

同样拥有顶部导航及侧边栏,区别是两边未留边距,多用于应用型的网站。

  1. import { Component } from '@angular/core';
  2. @Component({
  3. selector: 'nz-demo-layout-top-side-2',
  4. template: `
  5. <nz-layout class="layout">
  6. <nz-header>
  7. <div class="logo"></div>
  8. <ul nz-menu [nzTheme]="'dark'" [nzMode]="'horizontal'" style="line-height: 64px;">
  9. <li nz-menu-item>nav 1</li>
  10. <li nz-menu-item>nav 2</li>
  11. <li nz-menu-item>nav 3</li>
  12. </ul>
  13. </nz-header>
  14. <nz-layout>
  15. <nz-sider [nzWidth]="200" style="background:#fff">
  16. <ul nz-menu [nzMode]="'inline'" style="height:100%">
  17. <li nz-submenu>
  18. <span title><i nz-icon type="user"></i>subnav 1</span>
  19. <ul>
  20. <li nz-menu-item>option1</li>
  21. <li nz-menu-item>option2</li>
  22. <li nz-menu-item>option3</li>
  23. <li nz-menu-item>option4</li>
  24. </ul>
  25. </li>
  26. <li nz-submenu>
  27. <span title><i nz-icon type="laptop"></i>subnav 2</span>
  28. <ul>
  29. <li nz-menu-item>option5</li>
  30. <li nz-menu-item>option6</li>
  31. <li nz-menu-item>option7</li>
  32. <li nz-menu-item>option8</li>
  33. </ul>
  34. </li>
  35. <li nz-submenu>
  36. <span title><i nz-icon type="notification"></i>subnav 3</span>
  37. <ul>
  38. <li nz-menu-item>option9</li>
  39. <li nz-menu-item>option10</li>
  40. <li nz-menu-item>option11</li>
  41. <li nz-menu-item>option12</li>
  42. </ul>
  43. </li>
  44. </ul>
  45. </nz-sider>
  46. <nz-layout style="padding:0 24px 24px">
  47. <nz-breadcrumb style="margin:16px 0;">
  48. <nz-breadcrumb-item>Home</nz-breadcrumb-item>
  49. <nz-breadcrumb-item>List</nz-breadcrumb-item>
  50. <nz-breadcrumb-item>App</nz-breadcrumb-item>
  51. </nz-breadcrumb>
  52. <nz-content style="background:#fff; padding: 24px; min-height: 280px;">Content</nz-content>
  53. </nz-layout>
  54. </nz-layout>
  55. </nz-layout>
  56. `,
  57. styles: [
  58. `
  59. .logo {
  60. width: 120px;
  61. height: 31px;
  62. background: rgba(255, 255, 255, 0.2);
  63. margin: 16px 28px 16px 0;
  64. float: left;
  65. }
  66. `
  67. ]
  68. })
  69. export class NzDemoLayoutTopSide2Component {}

Layout布局 - 图4

顶部-侧边布局

拥有顶部导航及侧边栏的页面,多用于展示类网站。

  1. import { Component } from '@angular/core';
  2. @Component({
  3. selector: 'nz-demo-layout-top-side',
  4. template: `
  5. <nz-layout class="layout">
  6. <nz-header>
  7. <div class="logo"></div>
  8. <ul nz-menu [nzTheme]="'dark'" [nzMode]="'horizontal'" style="line-height: 64px;">
  9. <li nz-menu-item>nav 1</li>
  10. <li nz-menu-item>nav 2</li>
  11. <li nz-menu-item>nav 3</li>
  12. </ul>
  13. </nz-header>
  14. <nz-content style="padding:0 50px;">
  15. <nz-breadcrumb style="margin:16px 0;">
  16. <nz-breadcrumb-item>Home</nz-breadcrumb-item>
  17. <nz-breadcrumb-item>List</nz-breadcrumb-item>
  18. <nz-breadcrumb-item>App</nz-breadcrumb-item>
  19. </nz-breadcrumb>
  20. <nz-layout style="padding:24px 0; background: #fff">
  21. <nz-sider [nzWidth]="200" style="background:#fff">
  22. <ul nz-menu [nzMode]="'inline'" style="height:100%">
  23. <li nz-submenu>
  24. <span title><i nz-icon type="user"></i>subnav 1</span>
  25. <ul>
  26. <li nz-menu-item>option1</li>
  27. <li nz-menu-item>option2</li>
  28. <li nz-menu-item>option3</li>
  29. <li nz-menu-item>option4</li>
  30. </ul>
  31. </li>
  32. <li nz-submenu>
  33. <span title><i nz-icon type="laptop"></i>subnav 2</span>
  34. <ul>
  35. <li nz-menu-item>option5</li>
  36. <li nz-menu-item>option6</li>
  37. <li nz-menu-item>option7</li>
  38. <li nz-menu-item>option8</li>
  39. </ul>
  40. </li>
  41. <li nz-submenu>
  42. <span title><i nz-icon type="notification"></i>subnav 3</span>
  43. <ul>
  44. <li nz-menu-item>option9</li>
  45. <li nz-menu-item>option10</li>
  46. <li nz-menu-item>option11</li>
  47. <li nz-menu-item>option12</li>
  48. </ul>
  49. </li>
  50. </ul>
  51. </nz-sider>
  52. <nz-content style="padding: 0 24px; min-height: 280px;">Content</nz-content>
  53. </nz-layout>
  54. <nz-footer style="text-align: center;">Ant Design ©2019 Implement By Angular</nz-footer>
  55. </nz-content>
  56. </nz-layout>
  57. `,
  58. styles: [
  59. `
  60. .logo {
  61. width: 120px;
  62. height: 31px;
  63. background: rgba(255, 255, 255, 0.2);
  64. margin: 16px 28px 16px 0;
  65. float: left;
  66. }
  67. `
  68. ]
  69. })
  70. export class NzDemoLayoutTopSideComponent {}

Layout布局 - 图5

侧边布局

侧边两列式布局。页面横向空间有限时,侧边导航可收起。

侧边导航在页面布局上采用的是左右的结构,一般主导航放置于页面的左侧固定位置,辅助菜单放置于工作区顶部。内容根据浏览器终端进行自适应,能提高横向空间的使用率,但是整个页面排版不稳定。侧边导航的模式层级扩展性强,一、二、三级导航项目可以更为顺畅且具关联性的被展示,同时侧边导航可以固定,使得用户在操作和浏览中可以快速的定位和切换当前位置,有很高的操作效率。但这类导航横向页面内容的空间会被牺牲一部份。

  1. import { Component } from '@angular/core';
  2. @Component({
  3. selector: 'nz-demo-layout-side',
  4. template: `
  5. <nz-layout>
  6. <nz-sider nzCollapsible [(nzCollapsed)]="isCollapsed" [nzWidth]="width" [nzReverseArrow]="isReverseArrow">
  7. <div class="logo"></div>
  8. <ul nz-menu [nzTheme]="'dark'" [nzMode]="'inline'" [nzInlineCollapsed]="isCollapsed">
  9. <li nz-submenu>
  10. <span title><i nz-icon type="user"></i><span class="nav-text">User</span></span>
  11. <ul>
  12. <li nz-menu-item>Tom</li>
  13. <li nz-menu-item>Bill</li>
  14. <li nz-menu-item>Alex</li>
  15. </ul>
  16. </li>
  17. <li nz-submenu>
  18. <span title><i nz-icon type="team"></i><span class="nav-text">Team</span></span>
  19. <ul>
  20. <li nz-menu-item>Team 1</li>
  21. <li nz-menu-item>Team 2</li>
  22. </ul>
  23. </li>
  24. <li nz-menu-item>
  25. <span><i nz-icon type="file"></i><span class="nav-text">File</span></span>
  26. </li>
  27. </ul>
  28. </nz-sider>
  29. <nz-layout>
  30. <nz-header style="background: #fff; padding:0;"></nz-header>
  31. <nz-content style="margin:0 16px;">
  32. <nz-breadcrumb style="margin:16px 0;">
  33. <nz-breadcrumb-item>User</nz-breadcrumb-item>
  34. <nz-breadcrumb-item>Bill</nz-breadcrumb-item>
  35. </nz-breadcrumb>
  36. <div style="padding:24px; background: #fff; min-height: 360px;">
  37. Bill is a cat.
  38. </div>
  39. </nz-content>
  40. <nz-footer style="text-align: center;">Ant Design ©2019 Implement By Angular</nz-footer>
  41. </nz-layout>
  42. </nz-layout>
  43. `,
  44. styles: [
  45. `
  46. .logo {
  47. height: 32px;
  48. background: rgba(255, 255, 255, 0.2);
  49. margin: 16px;
  50. }
  51. `
  52. ]
  53. })
  54. export class NzDemoLayoutSideComponent {
  55. isCollapsed = false;
  56. isReverseArrow = false;
  57. width = 200;
  58. }

Layout布局 - 图6

自定义触发器

要使用自定义触发器,可以设置 nzTrigger={null} 来隐藏默认设定。

  1. import { Component, TemplateRef, ViewChild } from '@angular/core';
  2. @Component({
  3. selector: 'nz-demo-layout-custom-trigger',
  4. template: `
  5. <nz-layout>
  6. <nz-sider nzCollapsible [(nzCollapsed)]="isCollapsed" [nzTrigger]="triggerTemplate">
  7. <div class="logo"></div>
  8. <ul nz-menu [nzTheme]="'dark'" [nzMode]="'inline'" [nzInlineCollapsed]="isCollapsed">
  9. <li nz-submenu>
  10. <span title><i nz-icon type="user"></i><span class="nav-text">User</span></span>
  11. <ul>
  12. <li nz-menu-item>Tom</li>
  13. <li nz-menu-item>Bill</li>
  14. <li nz-menu-item>Alex</li>
  15. </ul>
  16. </li>
  17. <li nz-submenu>
  18. <span title><i nz-icon type="team"></i><span class="nav-text">Team</span></span>
  19. <ul>
  20. <li nz-menu-item>Team 1</li>
  21. <li nz-menu-item>Team 2</li>
  22. </ul>
  23. </li>
  24. <li nz-menu-item>
  25. <span><i nz-icon type="file"></i><span class="nav-text">File</span></span>
  26. </li>
  27. </ul>
  28. </nz-sider>
  29. <nz-layout>
  30. <nz-header style="background: #fff; padding:0;">
  31. <i
  32. class="trigger"
  33. nz-icon
  34. [type]="isCollapsed ? 'menu-unfold' : 'menu-fold'"
  35. (click)="isCollapsed = !isCollapsed"
  36. ></i>
  37. </nz-header>
  38. <nz-content style="margin:0 16px;">
  39. <nz-breadcrumb style="margin:16px 0;">
  40. <nz-breadcrumb-item>User</nz-breadcrumb-item>
  41. <nz-breadcrumb-item>Bill</nz-breadcrumb-item>
  42. </nz-breadcrumb>
  43. <div style="padding:24px; background: #fff; min-height: 360px;">
  44. Bill is a cat.
  45. </div>
  46. </nz-content>
  47. <nz-footer style="text-align: center;">Ant Design ©2019 Implement By Angular</nz-footer>
  48. </nz-layout>
  49. </nz-layout>
  50. <ng-template #trigger>
  51. <i nz-icon type="up"></i>
  52. </ng-template>
  53. `,
  54. styles: [
  55. `
  56. .trigger {
  57. font-size: 18px;
  58. line-height: 64px;
  59. padding: 0 24px;
  60. cursor: pointer;
  61. transition: color 0.3s;
  62. }
  63. .trigger:hover {
  64. color: #1890ff;
  65. }
  66. .logo {
  67. height: 32px;
  68. background: rgba(255, 255, 255, 0.2);
  69. margin: 16px;
  70. }
  71. `
  72. ]
  73. })
  74. export class NzDemoLayoutCustomTriggerComponent {
  75. isCollapsed = false;
  76. triggerTemplate: TemplateRef<void> | null = null;
  77. @ViewChild('trigger') customTrigger: TemplateRef<void>;
  78. /** custom trigger can be TemplateRef **/
  79. changeTrigger(): void {
  80. this.triggerTemplate = this.customTrigger;
  81. }
  82. }

Layout布局 - 图7

响应式布局

nz-sider 支持响应式布局。

说明:配置 nzBreakpoint 属性即生效,视窗宽度小于 nzBreakpointnz-sider 缩小为 nzCollapsedWidth 宽度,若将 nzCollapsedWidth 设置为零,会出现特殊 trigger。

  1. import { Component } from '@angular/core';
  2. @Component({
  3. selector: 'nz-demo-layout-responsive',
  4. template: `
  5. <nz-layout>
  6. <nz-sider
  7. nzCollapsible
  8. [(nzCollapsed)]="isCollapsed"
  9. [nzBreakpoint]="'lg'"
  10. [nzCollapsedWidth]="0"
  11. [nzZeroTrigger]="zeroTrigger"
  12. >
  13. <div class="logo"></div>
  14. <ul nz-menu [nzTheme]="'dark'" [nzMode]="'inline'" [nzInlineCollapsed]="isCollapsed">
  15. <li nz-menu-item>
  16. <span><i nz-icon type="user"></i><span class="nav-text">nav 1</span></span>
  17. </li>
  18. <li nz-menu-item>
  19. <span><i nz-icon type="video-camera"></i><span class="nav-text">nav 2</span></span>
  20. </li>
  21. <li nz-menu-item>
  22. <span><i nz-icon type="upload"></i><span class="nav-text">nav 3</span></span>
  23. </li>
  24. <li nz-menu-item>
  25. <span><i nz-icon type="user"></i><span class="nav-text">nav 4</span></span>
  26. </li>
  27. </ul>
  28. </nz-sider>
  29. <nz-layout>
  30. <nz-header style="background: #fff; padding:0;"></nz-header>
  31. <nz-content style="margin:24px 16px 0;">
  32. <div style="padding:24px; background: #fff; min-height: 360px;">
  33. Content
  34. </div>
  35. </nz-content>
  36. <nz-footer style="text-align: center;">Ant Design ©2019 Implement By Angular</nz-footer>
  37. </nz-layout>
  38. </nz-layout>
  39. <ng-template #zeroTrigger>
  40. <i nz-icon type="menu-fold" theme="outline"></i>
  41. </ng-template>
  42. `,
  43. styles: [
  44. `
  45. .logo {
  46. height: 32px;
  47. background: rgba(255, 255, 255, 0.2);
  48. margin: 16px;
  49. }
  50. `
  51. ]
  52. })
  53. export class NzDemoLayoutResponsiveComponent {
  54. isCollapsed = false;
  55. }

Layout布局 - 图8

固定头部

一般用于固定顶部导航,方便页面切换。

  1. import { Component } from '@angular/core';
  2. @Component({
  3. selector: 'nz-demo-layout-fixed',
  4. template: `
  5. <nz-layout class="layout">
  6. <nz-header style="position:fixed; width:100%">
  7. <div class="logo"></div>
  8. <ul nz-menu [nzTheme]="'dark'" [nzMode]="'horizontal'" style="line-height: 64px;">
  9. <li nz-menu-item>nav 1</li>
  10. <li nz-menu-item>nav 2</li>
  11. <li nz-menu-item>nav 3</li>
  12. </ul>
  13. </nz-header>
  14. <nz-content style="padding:0 50px;margin-top:64px;">
  15. <nz-breadcrumb style="margin:16px 0;">
  16. <nz-breadcrumb-item>Home</nz-breadcrumb-item>
  17. <nz-breadcrumb-item>List</nz-breadcrumb-item>
  18. <nz-breadcrumb-item>App</nz-breadcrumb-item>
  19. </nz-breadcrumb>
  20. <div style="background:#fff; padding: 24px; min-height: 380px;">Content</div>
  21. </nz-content>
  22. <nz-footer style="text-align: center;">Ant Design ©2019 Implement By Angular</nz-footer>
  23. </nz-layout>
  24. `,
  25. styles: [
  26. `
  27. .logo {
  28. width: 120px;
  29. height: 31px;
  30. background: rgba(255, 255, 255, 0.2);
  31. margin: 16px 24px 16px 0;
  32. float: left;
  33. }
  34. `
  35. ]
  36. })
  37. export class NzDemoLayoutFixedComponent {}

Layout布局 - 图9

固定侧边栏

当内容较长时,使用固定侧边栏可以提供更好的体验。

  1. import { Component } from '@angular/core';
  2. @Component({
  3. selector: 'nz-demo-layout-fixed-sider',
  4. template: `
  5. <nz-layout>
  6. <nz-sider style="overflow: auto; height: 100vh; position: fixed; left: 0">
  7. <div class="logo"></div>
  8. <ul nz-menu [nzTheme]="'dark'" [nzMode]="'inline'">
  9. <li nz-menu-item>
  10. <span><i nz-icon type="file"></i><span class="nav-text">nav 1</span></span>
  11. </li>
  12. <li nz-menu-item>
  13. <span><i nz-icon type="video-camera"></i><span class="nav-text">nav 2</span></span>
  14. </li>
  15. <li nz-menu-item>
  16. <span><i nz-icon type="upload"></i><span class="nav-text">nav 3</span></span>
  17. </li>
  18. <li nz-menu-item>
  19. <span><i nz-icon type="bar-chart"></i><span class="nav-text">nav 4</span></span>
  20. </li>
  21. <li nz-menu-item>
  22. <span><i nz-icon type="cloud-o"></i><span class="nav-text">nav 5</span></span>
  23. </li>
  24. <li nz-menu-item>
  25. <span><i nz-icon type="appstore-o"></i><span class="nav-text">nav 6</span></span>
  26. </li>
  27. <li nz-menu-item>
  28. <span><i nz-icon type="team"></i><span class="nav-text">nav 7</span></span>
  29. </li>
  30. <li nz-menu-item>
  31. <span><i nz-icon type="shop"></i><span class="nav-text">nav 8</span></span>
  32. </li>
  33. </ul>
  34. </nz-sider>
  35. <nz-layout style="margin-left: 200">
  36. <nz-header style="background: #fff; padding:0;"></nz-header>
  37. <nz-content style="margin:24px 16px 0;overflow: initial">
  38. <div style="padding: 24px; background: #fff; text-align: center">
  39. ...
  40. <br />
  41. Really
  42. <br />...<br />...<br />...<br />
  43. long
  44. <br />...<br />...<br />...<br />...<br />...<br />...
  45. <br />...<br />...<br />...<br />...<br />...<br />...
  46. <br />...<br />...<br />...<br />...<br />...<br />...
  47. <br />...<br />...<br />...<br />...<br />...<br />...
  48. <br />...<br />...<br />...<br />...<br />...<br />...
  49. <br />...<br />...<br />...<br />...<br />...<br />... <br />...<br />...<br />...<br />...<br />...<br />
  50. content
  51. </div>
  52. </nz-content>
  53. <nz-footer style="text-align: center;">Ant Design ©2019 Implement By Angular</nz-footer>
  54. </nz-layout>
  55. </nz-layout>
  56. `,
  57. styles: [
  58. `
  59. .logo {
  60. height: 32px;
  61. background: rgba(255, 255, 255, 0.2);
  62. margin: 16px;
  63. }
  64. `
  65. ]
  66. })
  67. export class NzDemoLayoutFixedSiderComponent {}

API

  1. <nz-layout>
  2. <nz-header>header</nz-header>
  3. <nz-layout>
  4. <nz-sider>left sidebar</nz-sider>
  5. <nz-content>main content</nz-content>
  6. <nz-sider>right sidebar</nz-sider>
  7. </nz-layout>
  8. <nz-footer>footer</nz-footer>
  9. </nz-layout>

单独引入此组件

想要了解更多关于单独引入组件的内容,可以在快速上手页面进行查看。

  1. import { NzLayoutModule } from 'ng-zorro-antd';

nz-sidercomponent

侧边栏。

参数说明类型默认值
[nzBreakpoint]触发响应式布局的断点'xs'|'sm'|'md'|'lg'|'xl'|'xxl'-
[nzCollapsed]当前收起状态boolean-
[nzCollapsedWidth]收缩宽度,设置为 0 会出现特殊 triggernumber64
[nzCollapsible]是否可收起booleanfalse
[nzCollapsed]当前收起状态,可双向绑定booleanfalse
[nzReverseArrow]翻转折叠提示箭头的方向,当 Sider 在右边时可以使用booleanfalse
[nzTrigger]自定义 trigger,设置为 null 时隐藏 triggerTemplateRef<void>-
[nzZeroTrigger]自定义 nzCollapsedWidth 为 0 时的 特殊triggerTemplateRef<void>-
[nzWidth]宽度number|string200
[nzTheme]主题颜色'light'|'dark'dark
(nzCollapsedChange)展开-收起时的回调函数EventEmitter<boolean>-

breakpoint width

  1. {
  2. xs: '480px',
  3. sm: '768px',
  4. md: '992px',
  5. lg: '1200px',
  6. xl: '1600px',
  7. xxl: '1600px'
  8. }