文本不换行并忽略换行符

时间:2019-07-17 15:27:53

标签: html css

我正在尝试在网页中显示文本,该文本中嵌入了\n(或换行符),但是仍然显示在一行中。我想念什么?

<span ng-bind-html="$ctrl.convertToTrusted($ctrl.post.content)" class="ng-binding">hey john
Content from post:
Peter Smith
July 14 at 1:19 PM
I wish it will rain today
</span>

实际上是这样显示的:

enter image description here

1 个答案:

答案 0 :(得分:3)

white-space: pre-line规则尊重换行符。但是,我从未见过它实际用于生产代码中。

.element {
    white-space: pre-line;
}