How do I set the table cell widths to minimum except last column?

前端 未结 7 1488
独厮守ぢ
独厮守ぢ 2020-12-07 11:44

I have a table with 100% width. If I put s in it, they get spread out with equal length columns. However, I want all the columns except last to have a

7条回答
  •  Happy的楠姐
    2020-12-07 12:01

    td:not(:last-child){
        white-space: nowrap;
    }
    
    td:last-child{
        width: 100%;
    }
    

    By using the code above, the last table-cell will try to be as big as possible, and you will prevent the ones before that from wrapping. This does the same as the other answers given, but way more efficient.

提交回复
热议问题