【问题标题】:Align the Columns of the Data-Table对齐数据表的列
【发布时间】:2018-06-02 16:08:49
【问题描述】:

我有一个angular-material 数据表,我希望它与某个列左/右对齐。

  <mat-table #table [dataSource]="dataSource" matSort>

    <ng-container matColumnDef="col0">
      <mat-header-cell *matHeaderCellDef mat-sort-header> Col0</mat-header-cell>
      <mat-cell *matCellDef="let element"> {{element.col0}} </mat-cell>
    </ng-container>

    <ng-container matColumnDef="col1">
      <mat-header-cell *matHeaderCellDef mat-sort-header> Col1 </mat-header-cell>
      <mat-cell *matCellDef="let element"> {{element.col1}} </mat-cell>
    </ng-container>

    <mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
    <mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row>
  </mat-table>

我需要什么 CSS 来做这个?

【问题讨论】:

    标签: html css angularjs angular-material


    【解决方案1】:

    经过几次谷歌搜索后,我以 github 更改请求的形式找到了解决方案: See here

    简写如下:

    .mat-column-col1 {
        display: flex;
        justify-content: flex-end;
    }
    

    只需将 col1 替换为您需要的列!

    【讨论】:

    • 在新的 Angular 版本 (6+) 中删除 display:flex。有关更多信息,请参阅答案中的链接。
    猜你喜欢
    • 2012-06-17
    • 1970-01-01
    • 2016-06-15
    • 2019-10-29
    • 2013-06-04
    • 1970-01-01
    • 1970-01-01
    • 2016-12-30
    • 2015-05-05
    相关资源
    最近更新 更多