md-table - How to update the column width

后端 未结 18 2145
离开以前
离开以前 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:20

    Right now, it has not been exposed at API level yet. However you can achieve it using something similar to this

    
       ID 
       {{row.id}} 
    
    

    In css, you need to add this custom class -

    .customWidthClass{
       flex: 0 0 75px;
    }
    

    Feel free to enter the logic to append class or custom width in here. It will apply custom width for the column.

    Since md-table uses flex, we need to give fixed width in flex manner. This simply explains -

    0 = don't grow (shorthand for flex-grow)

    0 = don't shrink (shorthand for flex-shrink)

    75px = start at 75px (shorthand for flex-basis)

    Plunkr here - https://plnkr.co/edit/v7ww6DhJ6zCaPyQhPRE8?p=preview

提交回复
热议问题