如何在表单元格中显示多行文本 [英] How to show multiline text in a table cell

查看:168
本文介绍了如何在表单元格中显示多行文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我想将一个段落从数据库显示到表格单元格中。

So , I want to show a paragraph from database into a table cell.

结果是一个大的1行,忽略它在数据库中的组织。
忽略'输入'例如(新行)

The result is a large 1 line, ignoring how its organised in database. ignoring 'enters' for example (new lines)

我想根据它在数据库中的写法来显示它。

I want to show it exactly according to how it's written in database.

例如,如果段落保存如下:

for example if paragraph is saved like this :

hello ,
my name is x.

我想让它像这样显示,而不是:

I want it to be showed exactly like that , instead of :

hello, myname is x.


推荐答案

您要使用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.

这篇关于如何在表单元格中显示多行文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆