Lock table cells to their default size regardless of content

前端 未结 8 2081
栀梦
栀梦 2021-01-02 13:25

If I have

8条回答
  •  灰色年华
    2021-01-02 13:27

    You could try to pick a single cell to chew up all the space and set that to 100% height and width:

    Hi There. x
    Here is some text.

    and some CSS:

    table {
        width: 100%;
        height: 100%;
    }
    td {
        white-space: nowrap;
    }
    td.space-hog {
        width: 100%;
        height: 100%;
    }
    

    And a live example. You need to be careful to avoid unpleasant line wrapping when .space-hog does its thing, hence the white-space: nowrap. If you put the .space-hog in the last row then you can avoid pushing the interesting parts down.

提交回复
热议问题