How to Auto resize HTML table cell to fit the text size

前端 未结 3 1574
北海茫月
北海茫月 2020-12-05 06:28

I have a table with 2 rows and variable columns. I tried width = 100% for the column. So the first content in the view will fit. But suppose if i am changing the contents dy

3条回答
  •  隐瞒了意图╮
    2020-12-05 06:51

    You can try this:

    HTML

    element1 data junk here last column
    elem more data other stuff again, last column
    more of these rows

    CSS

    table {
        border: 1px solid green;
        border-collapse: collapse;
        width:100%;
    }
    
    table td {
        border: 1px solid green;
    }
    
    table td.shrink {
        white-space:nowrap
    }
    table td.expand {
        width: 99%
    }
    

提交回复
热议问题