HTML - DIV内容中的Newline char可编辑? [英] HTML - Newline char in DIV content editable?
本文介绍了HTML - DIV内容中的Newline char可编辑?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在数据库中存储内容,例如:
I am storing content in the database, for example:
Hello
This
is
Text
当我将它传递给textarea时,它会保留新的换行符。但是,如果我将该文本传递给内容可编辑的div,它将保持如下:
and when I pass that to a textarea, it stays with the new line breaks. But if I pass that text to a div with content editable, it would stay like this:
Hello This is Text
如何解决这个问题?
推荐答案
在div上设置样式: white-space:pre
或白色空格:pre-wrap
Set a style on the div: white-space: pre
or white-space: pre-wrap
范例: http://jsfiddle.net/fPv6S/
这篇关于HTML - DIV内容中的Newline char可编辑?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文