Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to place Mat-Card Mat-card-action at bottom of card when we are creating cards dynamically

<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>

like image 833
veeru Avatar asked Apr 28 '18 21:04

veeru


2 Answers

Add in stylesheet:

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

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

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

font: https://github.com/angular/material2/issues/11094

like image 90
Eriel Miquilino Avatar answered Sep 21 '22 20:09

Eriel Miquilino


Solutions if you are using

<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>
  • add a class to the mat-card .card-internals { min-height: 200px; justify-content: space-between; display: flex; flex-direction: column; }

i you rather want a spacing like this

header
content

action

set

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

on mat card and margin: auto 0 0; on the mat card actions

like image 22
Ivan Tarskich Avatar answered Sep 20 '22 20:09

Ivan Tarskich