我想用卡片垂直列出数组中的元素,但它们之间没有空格。我尝试使用填充,但它似乎不起作用。
如何让这些卡片间隔开?
<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>
这是CSS
.asd {
width: 80%;
margin: 0 auto; /* Added */
}
.inputasd {
width: 100%;
}
.cardPadding {
padding: 100px;
margin-bottom: 50px;
}
最佳答案
.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;
...
}
关于css - 垂直分离 Angular Material 卡片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51931415/