Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在解决一个问题,即相同的输出在 html 页面上以不同的方式呈现。如果我有;
Test Test
作为数据库表中的一个条目,我的页面的一部分将允许行空间(我想要),但我的页面的另一部分不会,只是切掉空格,使它们看起来像
有人可以帮我确定可能的问题吗?
是的你是。除非您有一些 CSS 和/或<pre>标签来强制 HTML 遵守换行符,否则它们通常被视为空格。要在 HTML 中获得“换行符”,您必须使用<br />标签。
<pre>
<br />
(我不确定是否理解)
您必须转换\nin <br/>(如果您在 php 中,请使用函数 nl2br())
\n
<br/>