In HTML Table how do you force cell text to truncate and not increase the width of the cell or wrap

后端 未结 3 1135
太阳男子
太阳男子 2021-01-24 03:06

I have tried a number of CSS style settings, but can\'t seem to get it working, I either get the text to wrap or increase the size of the column.

I have tried setting ta

3条回答
  •  孤独总比滥情好
    2021-01-24 03:39

    Set a width on the entire table as well. The width can be set as a percentage, in pixels, or in other units. You might think that it suffices to set the width of each column, or the width of each cell in the first row, but for some odd reason it doesn’t.

    Fixed layout for tables has many quirks and oddities, and one of them is that if content does not fit, the column gets wider, unless the total width of the table has been set. This seems to happen so consistently in browsers that one might even think it’s part of the specs (but it isn’t, as far as I can see).

    If you want to set fixed width (with truncation when needed) for some column(s) without setting the total width, I’m afraid you need a workaround like

    ...
    with the width and overflow properties set on the div element.

提交回复
热议问题