文字不换行且忽略换行符 [英] Text not breaking line and ignoring line break characters
本文介绍了文字不换行且忽略换行符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在网页中显示文本,该文本中嵌入了\n
(或换行符),但是仍显示在一行中.我想念什么?
I'm trying to display text in my webpage, the text has \n
(or new line characters) embedded in it, however still displayed in one line. What am I missing?
<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>
实际上是这样显示的:
推荐答案
white-space: pre-line
规则尊重换行符.不过,我从未见过它实际用于生产代码中.
white-space: pre-line
rule respects the new line character. Though, I never saw it actually used in production code.
.element {
white-space: pre-line;
}
这篇关于文字不换行且忽略换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文