当我们动态创建卡片时,如何在卡片底部放置Mat-Card Mat-card-action

时间:2018-04-28 21:48:04

标签: css angular-material angular5 mat-card

<div class="col-xs-6 col-md-4 home-content" *ngFor="let s of abc">
    <mat-card>
        <mat-card-header>
            <mat-card-title>{{s.header}}</mat-card-title>
        </mat-card-header>
        <mat-card-content>
            <p> {{s.Desc}} </p>
        </mat-card-content>
        <mat-card-actions>
            <button mat-raised-button type="submit" color="primary">Submit</button>
        </mat-card-actions>
    </mat-card>
</div>
<div class="col-xs-6 col-md-4 home-content" *ngFor="let s of abc">
    <mat-card>
        <mat-card-header>
            <mat-card-title>{{s.header}}</mat-card-title>
        </mat-card-header>
        <mat-card-content>
            <p> {{s.Desc}} </p>
        </mat-card-content>
        <mat-card-actions>
            <button mat-raised-button type="submit" color="primary">Submit</button>
        </mat-card-actions>
    </mat-card>
</div>

2 个答案:

答案 0 :(得分:0)

添加样式表:

.mat-card{
  display:flex;
  flex-direction: column;
}

.mat-card-header {
  flex-shrink: 0;
}

.mat-card-content{
  flex-grow: 1;
  overflow: auto;
}

字体:https://github.com/angular/material2/issues/11094

答案 1 :(得分:0)

使用的解决方案

<mat-card>
  <mat-card-header>
    <mat-card-title>title</mat-card-title>
    <mat-card-subtitle>subtitle</mat-card-subtitle>
  </mat-card-header>
  <mat-card-content>
  
  </mat-card-content>
  <mat-card-actions>
    <button mat-button>Ok</button>
  </mat-card-actions>
</mat-card>
  • 向类别卡片.card-internals添加一个类{min-height:200px; 证明内容:间隔;显示:flex;伸缩方向: 柱; }

我宁愿这样的间距

header
content

action

设置

display: flex; justify-content: start; flex-direction: column; flex-wrap: wrap;

在垫卡上,margin: auto 0 0;在垫上 卡片动作