When Material creates the table it automagically applies two class-names for you which you can use to style each column.
In the the example below the styles is named mat-column-userId
and cdk-column-userId
.
<ng-container cdkColumnDef="userId">
<md-header-cell *cdkHeaderCellDef> ID </md-header-cell>
<md-cell *cdkCellDef="let row"> {{row.id}} </md-cell>
</ng-container>
Now you can use those names in css:
.mat-column-userId {
flex: 0 0 100px;
}
Similar to Rahul Patil's answer, but you don't need to add another class to your column definitions.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…