Angular material mat表格-如何更新列宽

Angular material mat表格-如何更新列宽,angular-material,mat-table,Angular Material,Mat Table,我的表有三列 第一列是数字,第三列是日期,第二列包含一个大字符串 我希望第一列是15px,第三列是100px,中间一列是剩余的宽度。百分之五,百分之八十五,百分之十 如何在mat表中实现这一点?您可以使用flex属性实现所需的行为 //First column and header .mat-header-cell:first-child,.mat-cell:first-child{ flex:5%; } //Second column and header .mat-header-cel

我的表有三列

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

我希望第一列是15px,第三列是100px,中间一列是剩余的宽度。百分之五,百分之八十五,百分之十


如何在mat表中实现这一点?

您可以使用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链接以查看演示


即使屏幕大小发生变化,是否有办法为列定义相同的大小?