Alp*_*zkn 6 css angular-material ngfor angular
我想用卡片垂直列出数组中的项目,但是它们之间没有空格。我尝试使用填充,但似乎不起作用。
我如何间隔这些卡?
<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>
Run Code Online (Sandbox Code Playgroud)
这是CSS
.asd {
width: 80%;
margin: 0 auto; /* Added */
}
.inputasd {
width: 100%;
}
.cardPadding {
padding: 100px;
margin-bottom: 50px;
}
Run Code Online (Sandbox Code Playgroud)
.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>
Run Code Online (Sandbox Code Playgroud)
.css/.scss 文件
.my-class-name{
margin-bottom: 10px;
...
}
Run Code Online (Sandbox Code Playgroud)