[html] span \n not work
紀錄一下之前遇到的問題,html在使用 <span> </span>時 字串內含有「\n」但顯示出來後"\n"後與\n前的字串卻是平行的,後來爬文之後,發現要在style多設定 「style="white-space: pre-line"」才行。
範例:
*字串 str = "123\n123"
1.未設定「white-space: pre-line」的<span>
hmtl:
<span>@str</span>
2.設定「white-space: pre-line」的<span>
hmtl:
<span style="white-space: pre-line">@str</span>
留言
張貼留言