md-table - How to update the column width

后端 未结 18 2129
离开以前
离开以前 2020-12-04 10:58

I have started using the md-table for my project, and I want fixed column width. Currently all columns width are divided into equal size.

Where can I get the documen

18条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-04 11:05

    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.

    
       ID 
       {{row.id}} 
    
    

    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.

提交回复
热议问题