谁能告诉我如何将 mat table 列标题及其内容居中 这是我的 html 代码
<div fxFlex fxLayout='column' fxLayoutAlign='center center'>
<mat-form-field>
<input matInput (keyup)="applyFilter($event.target.value)" placeholder="Filter">
</mat-form-field>
<table mat-table [dataSource]="dataSource" matSort class="mat-elevation-z8">
<ng-container matColumnDef="date">
<th mat-header-cell *matHeaderCellDef mat-sort-header> Date </th>
<td mat-cell *matCellDef="let element"> {{element.date | date}} </td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table>
<mat-paginator [pageSizeOptions]="[5, 10, 20]" showFirstLastButtons></mat-paginator>
</div>
我在小屏幕上得到这样的结果
最佳答案
将以下样式添加到全局 styles.scss
文件中:
th.mat-header-cell,
td.mat-cell {
text-align: center !important;
}
关于angular - 我如何居中 Angular Material 表列标题及其 mat-cell 内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59268987/