【问题标题】:mat-table - How to update the column widthmat-table - 如何更新列宽
【发布时间】:2018-12-28 02:44:21
【问题描述】:

我在 mat-table 中有三列。

第一列是数字,第三列是日期,第二列是一个大字符串。

我希望第一列是 15 像素,第三列是 100 像素,中间列是宽度。百分比 5%、85% 10%。

如何在 mat-table 中实现这一点?

【问题讨论】:

    标签: angular-material mat-table


    【解决方案1】:

    您可以使用 flex 属性来实现所需的行为。

     //First column and header
    .mat-header-cell:first-child,.mat-cell:first-child{
      flex:5%;
    }
    //Second column and header
    .mat-header-cell:nth-child(2),.mat-cell:nth-child(2){
      flex:85%;
    }
    //Last column and header
    .mat-header-cell:last-child,.mat-cell:last-child{
      flex:10%
    }
    

    这是查看演示的 stackblitz 链接。

    https://stackblitz.com/edit/angular-155qbp

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-18
    • 1970-01-01
    • 2019-07-23
    • 2018-07-02
    • 2021-01-28
    相关资源
    最近更新 更多