在textarea中保留换行符 [英] Preserve line breaks in textarea
问题描述
例如,如果我在textarea中写入:如果我在textarea中写入:
这是一个句子。这是另一个。这里还有一个。
这是一个新的段落。这是一个新的句子。
我需要相同的输出,不是:
这是一个句子。这是另一个。这里还有一个。这是一个新的
段落。这是一个新的句子。这是另一个。
我如何保留换行符?
通常您只需添加
white-space: pre-line;
将空格修剪为单个空格或
space:pre-wrap;
保留所有空格
添加到元素的样式(CSS) ,您希望您的文本以换行符呈现。
I have a form with a textarea and I want to preserve line breaks entered by the user when outputting the content.
For exemple, if I write in textarea :
Here is a sentence. Here is another. here is one more.
This is a new paragraph. Here is a new sentence. Here is another.
I want the same output and not :
Here is a sentence. Here is another. here is one more. This is a new paragraph. Here is a new sentence. Here is another.
How could I preserve line breaks?
Generally you just need to add
white-space: pre-line;
whitespace trimmed to single whitespace orwhite-space: pre-wrap;
all whitespace preserved
to the element's style (CSS), where you want your text rendered with line-breaks.
这篇关于在textarea中保留换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!