gpt4 book ai didi

html - 无需使用 BR 标签即可显示 html 中的段落

转载 作者:行者123 更新时间:2023-11-28 03:56:53 25 4
gpt4 key购买 nike

这真的只是一个简单的问题。我需要放 br 吗?在我的 HTML 中使用标记来正确分隔段落并在它们之间留行空间?

<p>
This is just a test example.

This is a new paragraph.

This is a third paragraph.
</p>

但是在我的网站中,它删除了所有段落换行符。为了获得中断,我必须在我的代码中插入两个换行符才能显示它。

<p>
This is just a test example.
<br /><br />
This is a new paragraph.
<br /><br />
This is a third paragraph.
</p>

有什么办法可以解决必须插入 <br> 的问题吗?不使用 pre标签,它似乎强制文本/字体的格式。

最佳答案

除了使用 <pre>标签,你可以使用 white-space: pre 为了尊重换行符。

p {
white-space: pre;
word-break: break-word;
}
<p>This is just a test example.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed sapien arcu, laoreet eget lobortis nec, volutpat in dui. Pellentesque luctus nibh feugiat, ultrices ex ac, porttitor mi. Vivamus vestibulum risus eu arcu tristique, quis blandit libero lacinia. Cras iaculis nec tortor sed consequat. Integer ornare pellentesque orci. Etiam malesuada imperdiet augue non elementum.

This is a third paragraph.
</p>

关于html - 无需使用 BR 标签即可显示 html 中的段落,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29108471/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com