插入换行
在 Unicode 中,0x000A 字符是专门控制换行的。在 CSS 中,我们可以写为 \000A 或 \A,我们可以用它来作为 ::after 伪元素的内容 ,并将其添加到指定元素的尾部,实现换行效果。
滚滚长江东逝水,浪花淘尽英雄。是非成败转头空。青山依旧在,几度夕阳红。白发渔樵江渚上,惯看秋月春风。一壶浊酒喜相逢。古今多少事,都付笑谈中。
vue
<template>
<div class="text-center">
<span class="br">滚滚长江东逝水,浪花淘尽英雄。</span>
<span class="br">是非成败转头空。青山依旧在,几度夕阳红。</span>
<span class="br">白发渔樵江渚上,惯看秋月春风。</span>
<span class="br">一壶浊酒喜相逢。古今多少事,都付笑谈中。</span>
</div>
</template>
<style lang="less">
.br::after {
content: '\A';
white-space: pre;
}
</style>