[英]how to center a title in mat card?
在我將 matcard 大小的高度設置為 10px 后,標題位置不正確,它不再位於卡片的中間。 我嘗試在 css 中使用 position 和 top 但沒有任何效果。 任何建議或幫助將不勝感激。
<mat-card class="alert" *ngIf="showBroadcast">
<mat-card-title *ngFor="let help of broadcastText | async">
<p style="font-size: 15px; color: black; top: 194px;">{{getMessage(help)}}</p>
</mat-card-title>
</mat-card>
.alert{
margin-bottom: 10px;
background-color: #D2232B;
border-radius: 6px;
opacity: 1;
height: 10px;
}
將容器顯示為flex
並將項目居中對齊:
https://stackblitz.com/edit/angular-mat-card-example-nm6ywr?file=src/app/app.component.css
.alert{
margin-bottom: 10px;
background-color: #D2232B;
border-radius: 6px;
opacity: 1;
height: 10px;
display: flex;
align-items: center;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.