且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在表单元格中显示多行文本

更新时间:2023-12-03 11:26:10

您要使用CSS white-space:pre 适当< td> 。要对所有表单元格执行此操作,例如:

You want to use the CSS white-space:pre applied to the appropriate <td>. To do this to all table cells, for example:

td { white-space:pre }

或者,如果您可以更改标记,可以使用 < pre> 标记。默认情况下,Web浏览器使用其用户代理样式表将相同的 white-space:pre 规则应用于此元素。

Alternatively, if you can change your markup, you can use a <pre> tag around your content. By default web browsers use their user-agent stylesheet to apply the same white-space:pre rule to this element.

PRE元素告诉可视用户代理,所包含的文本是预格式化的。处理预先设定的文字时,可视用户代理:

The PRE element tells visual user agents that the enclosed text is "preformatted". When handling preformatted text, visual user agents:


  • li>
  • 可以用固定字母字体呈现文本。

  • May leave white space intact.
  • May render text with a fixed-pitch font.
  • May disable automatic word wrap.
  • Must not disable bidirectional processing.