Skip to content
中文

TIP

In Unicode, the 0x000A character is specifically used to control line breaks. In CSS, we can write as\000Aor\A, we can use it as::afterpseudo-element content, and add it to the end of the specified element, achieve the newline effect.

海客談瀛洲,煙濤微茫信難求。越人語天姥,雲霞明滅或可覩。天姥連天向天橫,勢拔五嶽掩赤城。天台四萬八千丈,對此欲倒東南傾。
html
<div class="content">
  <span class="br">海客談瀛洲,煙濤微茫信難求。</span>
  <span class="br">越人語天姥,雲霞明滅或可覩。</span>
  <span class="br">天姥連天向天橫,勢拔五嶽掩赤城。</span>
  <span class="br">天台四萬八千丈,對此欲倒東南傾。</span>
</div>
scss
.content {
  .br::after {
    content: "\A";
    white-space: pre;
  }
}

https://lhammer.cn/You-need-to-know-css/#/line-breaks

Read or leave comments on GitHub