How to wrap table cell at a maximum width in full width table

前端 未结 6 1438
隐瞒了意图╮
隐瞒了意图╮ 2020-12-31 00:38

I\'d like to have a table with headers down the left hand side, the headers should be as narrow as possible, and the space for the values should take up the rest of the widt

6条回答
  •  独厮守ぢ
    2020-12-31 00:59

    If you know what the data is in the already, you could then wrap the long length text into a tag or so, and adjust the CSS slightly for that.

    UPDATED JSFIDDLE

    table {
        width: 100%;
    }
    th {
        text-align: right;
        white-space: nowrap;
    }
    th span {
        white-space: normal;
        word-break: break-all;
        display: block;
    }
    td {
        width: 100%;
    }
    Short Header value

    Short Header value
    Quite Long Header value

    Short Header value
    Quite Long Header value
    MMMMMMMMMMMMMMMMMMMMMMMMMMMassiveHeader value

提交回复
热议问题