1. 程式人生 > >html輸出文字,文章,識別其中的\n

html輸出文字,文章,識別其中的\n

只要在結果所在的 div 的 css 設定:

white-space: pre-line;

然後頁面就能成功識別 '\n' 並整齊的顯示結果了。

pre{
    text-indent: .2rem;
    color: #333333;
    font-size: .28rem;
    white-space: pre-line;
}