How to force table cell content to wrap?

前端 未结 9 1971
渐次进展
渐次进展 2020-11-28 01:59

Heres the entire page * wrappable is defined in a main.css file

/* Wrappable cell
* Add this class to make sure the text in a cell will wrap.
* By default, d         


        
9条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-28 02:23

    This worked for me when I needed to display "pretty" JSON in a cell:

    td { white-space:pre }
    

    More about the white-space property:

    • normal : This value directs user agents to collapse sequences of white space, and break lines as necessary to fill line boxes.

    • pre : This value prevents user agents from collapsing sequences of white space.
      Lines are only broken at preserved newline characters.

    • nowrap : This value collapses white space as for normal, but suppresses line breaks within text.

    • pre-wrap : This value prevents user agents from collapsing sequences of white space.
      Lines are broken at preserved newline characters, and as necessary to fill line boxes.

    • pre-line : This value directs user agents to collapse sequences of white space.
      Lines are broken at preserved newline characters, and as necessary to fill line boxes.

    (Also, see more at the source.)

提交回复
热议问题