Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Separating Angular Material cards vertically

I want to list items in an array vertically with cards, but there is no space between them. I tried to use padding but it seems it doesn't work.

card image

How can I have these cards spaced?

<ng-container *ngIf="titles?.length; else noTitle">
    <mat-card class="asd cardPardding" *ngFor="let title of titles">
      <p>
      {{title}}
      </p>
    </mat-card>
  </ng-container>

  <ng-template #noTitle>
    <mat-card class="asd cardPardding">
      <p>
      No title !
      </p>
  </mat-card>
  </ng-template>

This is css

.asd {
  width: 80%;
  margin: 0 auto; /* Added */
}

.inputasd {
  width: 100%;
}

.cardPadding {
  padding: 100px;
  margin-bottom: 50px;
}
like image 303
Alperzkn Avatar asked Aug 20 '18 13:08

Alperzkn


People also ask

How do I display two mat cards on the same row?

Try adding display: inline-block !

What is matcard?

<mat-card> is a content container for text, photos, and actions in the context of a single subject.

How do I change the height of my mat card?

Set fxFlexAlign="stretch" to have all mat-card in same height. Save this answer.

How do you use a Matcard?

The <mat-card> is a container for the content that can be used to insert the media, text & action in context to the single subject. The basic requirement for design the card is only an <mat-card> element that has some content in it, that will be used to build simple cards.


1 Answers

.component.html

<ng-container *ngIf="titles?.length; else noTitle">
    <mat-card class="my-class-name asd cardPardding" *ngFor="let title of titles">
        <p>
            {{title}}
        </p>
    </mat-card>
</ng-container>

<ng-template #noTitle>
    <mat-card class="asd cardPardding">
        <p>
            No title !
        </p>
    </mat-card>
</ng-template>

.css/.scss file

.my-class-name{
    margin-bottom: 10px;
    ... 
}
like image 98
Krishna Rathore Avatar answered Sep 23 '22 21:09

Krishna Rathore