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

前端 未结 7 1511
独厮守ぢ
独厮守ぢ 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条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-07 12:06

    You can set fix width by placing div tag inside td

    table {
        border: 1px solid green;
        border-collapse: collapse;
        width:100%;
    }
    
    table td {
        border: 1px solid green;
    }
    
    table td:nth-child(1) {
      width: 1%;
    }
    
    table td:nth-child(1) div {
      width: 300px;
    }
    element1 element1 element1 element1 element1 element1
    data junk here last column
    element2
    data junk here last column
    element3
    data junk here last column

    https://jsfiddle.net/8bf17o1v/

提交回复
热议问题