Card卡片

    最基础的卡片容器,可承载文字、列表、图片、段落,常用于后台概览页面。

    典型卡片

    包含标题、内容、操作区域。

    1. @Component({
    2. selector: 'nz-demo-card-basic',
    3. template: `
    4. <nz-card style="width:300px;" nzTitle="Card title" [nzExtra]="extraTemplate">
    5. <p>Card content</p>
    6. <p>Card content</p>
    7. <p>Card content</p>
    8. </nz-card>
    9. <ng-template #extraTemplate>
    10. <a>More</a>
    11. </ng-template>
    12. `,
    13. styles: [
    14. `
    15. p {
    16. margin: 0;
    17. }
    18. `
    19. ]
    20. })
    21. export class NzDemoCardBasicComponent {}

    Card卡片 - 图4

    无边框

    在灰色背景上使用无边框的卡片。

    1. import { Component } from '@angular/core';
    2. @Component({
    3. selector: 'nz-demo-card-border-less',
    4. template: `
    5. <div style="background: #ECECEC;padding:30px;">
    6. <nz-card style="width:300px;" [nzBordered]="false" nzTitle="Card title" [nzExtra]="extraTemplate">
    7. <p>Card content</p>
    8. <p>Card content</p>
    9. <p>Card content</p>
    10. </nz-card>
    11. </div>
    12. <ng-template #extraTemplate>
    13. <a>More</a>
    14. </ng-template>
    15. `,
    16. styles: [
    17. `
    18. p {
    19. margin: 0;
    20. }
    21. `
    22. ]
    23. })
    24. export class NzDemoCardBorderLessComponent {}

    简洁卡片

    只包含内容区域。

    1. import { Component } from '@angular/core';
    2. @Component({
    3. selector: 'nz-demo-card-simple',
    4. template: `
    5. <nz-card style="width:300px;">
    6. <p>Card content</p>
    7. <p>Card content</p>
    8. <p>Card content</p>
    9. </nz-card>
    10. `,
    11. styles: [
    12. `
    13. p {
    14. margin: 0;
    15. }
    16. `
    17. ]
    18. })

    更灵活的内容展示

    可以利用 nz-card-meta 支持更灵活的内容。

    Card卡片 - 图7

    栅格卡片

    在系统概览页面常常和栅格进行配合。

    1. import { Component } from '@angular/core';
    2. @Component({
    3. selector: 'nz-demo-card-in-column',
    4. template: `
    5. <div style="background: #ECECEC;padding:30px;">
    6. <div nz-row [nzGutter]="8">
    7. <div nz-col [nzSpan]="8">
    8. <nz-card nzTitle="Card title">
    9. <p>Card content</p>
    10. </nz-card>
    11. </div>
    12. <div nz-col [nzSpan]="8">
    13. <nz-card nzTitle="Card title">
    14. <p>Card content</p>
    15. </div>
    16. <div nz-col [nzSpan]="8">
    17. <nz-card nzTitle="Card title">
    18. <p>Card content</p>
    19. </nz-card>
    20. </div>
    21. </div>
    22. </div>
    23. `,
    24. styles: [
    25. `
    26. p {
    27. margin: 0;
    28. }
    29. `
    30. ]
    31. })
    32. export class NzDemoCardInColumnComponent {}

    预加载的卡片

    数据读入前会有文本块样式。

    1. import { Component } from '@angular/core';
    2. @Component({
    3. selector: 'nz-demo-card-loading',
    4. template: `
    5. <nz-switch [(ngModel)]="loading"></nz-switch>
    6. <nz-card style="width: 300px;margin-top: 16px" [nzLoading]="loading">
    7. <nz-card-meta [nzAvatar]="avatarTemplate" nzTitle="Card title" nzDescription="This is the description"></nz-card-meta>
    8. </nz-card>
    9. <nz-card style="width: 300px;margin-top: 16px" [nzActions]="[actionSetting, actionEdit, actionEllipsis]">
    10. <nz-skeleton [nzActive]="true" [nzLoading]="loading" [nzAvatar]="{ size: 'large' }">
    11. <nz-card-meta [nzAvatar]="avatarTemplate" nzTitle="Card title" nzDescription="This is the description"></nz-card-meta>
    12. </nz-skeleton>
    13. </nz-card>
    14. <ng-template #avatarTemplate>
    15. <nz-avatar nzSrc="https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png"></nz-avatar>
    16. </ng-template>
    17. <ng-template #actionSetting>
    18. <i nz-icon nzType="setting"></i>
    19. </ng-template>
    20. <ng-template #actionEdit>
    21. <i nz-icon nzType="edit"></i>
    22. </ng-template>
    23. <ng-template #actionEllipsis>
    24. <i nz-icon nzType="ellipsis"></i>
    25. </ng-template>
    26. `
    27. })
    28. export class NzDemoCardLoadingComponent {
    29. loading = true;
    30. }

    Card卡片 - 图9

    网格型内嵌卡片

    1. import { Component } from '@angular/core';
    2. @Component({
    3. selector: 'nz-demo-card-grid-card',
    4. template: `
    5. <nz-card nzTitle="Cart Title">
    6. <div nz-card-grid [ngStyle]="gridStyle">Content</div>
    7. <div nz-card-grid [ngStyle]="gridStyle">Content</div>
    8. <div nz-card-grid [ngStyle]="gridStyle">Content</div>
    9. <div nz-card-grid [ngStyle]="gridStyle">Content</div>
    10. <div nz-card-grid [ngStyle]="gridStyle">Content</div>
    11. <div nz-card-grid [ngStyle]="gridStyle">Content</div>
    12. </nz-card>
    13. `
    14. })
    15. export class NzDemoCardGridCardComponent {
    16. gridStyle = {
    17. width: '25%',
    18. textAlign: 'center'
    19. };
    20. }

    内部卡片

    可以放在普通卡片内部,展示多层级结构的信息。

    Card卡片 - 图11

    带页签的卡片

    可承载更多内容。

    1. import { Component } from '@angular/core';
    2. @Component({
    3. selector: 'nz-demo-card-tabs',
    4. template: `
    5. <nz-card style="width: 100%;" nzTitle="Card title" [nzExtra]="extraTemplate">
    6. <nz-card-tab>
    7. <nz-tabset nzSize="large" [(nzSelectedIndex)]="index1">
    8. <nz-tab nzTitle="tab1"></nz-tab>
    9. <nz-tab nzTitle="tab2"></nz-tab>
    10. </nz-tabset>
    11. </nz-card-tab>
    12. </nz-card>
    13. <ng-template #extraTemplate>
    14. <a>More</a>
    15. </ng-template>
    16. <br />
    17. <br />
    18. <nz-card style="width: 100%;">
    19. <nz-card-tab>
    20. <nz-tabset nzSize="large" [(nzSelectedIndex)]="index2">
    21. <nz-tab nzTitle="article"></nz-tab>
    22. <nz-tab nzTitle="app"></nz-tab>
    23. <nz-tab nzTitle="project"></nz-tab>
    24. </nz-tabset>
    25. </nz-card-tab>
    26. content{{ index2 }}
    27. </nz-card>
    28. `
    29. })
    30. export class NzDemoCardTabsComponent {
    31. index1 = 0;
    32. index2 = 0;
    33. }

    支持更多内容配置

    一种支持封面、头像、标题和描述信息的卡片。

    1. import { Component } from '@angular/core';
    2. @Component({
    3. selector: 'nz-demo-card-meta',
    4. template: `
    5. <nz-card style="width:300px;" [nzCover]="coverTemplate" [nzActions]="[actionSetting, actionEdit, actionEllipsis]">
    6. <nz-card-meta nzTitle="Card title" nzDescription="This is the description" [nzAvatar]="avatarTemplate"></nz-card-meta>
    7. </nz-card>
    8. <ng-template #avatarTemplate>
    9. <nz-avatar nzSrc="https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png"></nz-avatar>
    10. </ng-template>
    11. <ng-template #coverTemplate>
    12. <img alt="example" src="https://gw.alipayobjects.com/zos/rmsportal/JiqGstEfoWAOHiTxclqi.png" />
    13. </ng-template>
    14. <ng-template #actionSetting>
    15. <i nz-icon nzType="setting"></i>
    16. </ng-template>
    17. <ng-template #actionEdit>
    18. <i nz-icon nzType="edit"></i>
    19. </ng-template>
    20. <ng-template #actionEllipsis>
    21. <i nz-icon nzType="ellipsis"></i>
    22. </ng-template>
    23. `
    24. })
    25. export class NzDemoCardMetaComponent {}
    1. <nz-card nzTitle="卡片标题">卡片内容</nz-card>

    分隔卡片内容区域