文本里面的新行 [英] New line in text inside div

查看:95
本文介绍了文本里面的新行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在文本区域中,有一些新行使用例如
 ,但是如何在div元素中使用htmll \ n)?

In a textarea, there are new lines using for example 
, but how can I do this to a div element without using htmll (plain text like \n) ?

推荐答案

您可以使用CSS强制HTML将换行符识别为换行符。

You can use CSS to force HTML to recognize new lines as line breaks.

只需将 white-space 属性设置为 pre

div {
    white-space: pre;
}

演示

这篇关于文本里面的新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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