示例工程 05-comments-entities
05-comments-entities/demo-02-whitespace/index.html
点击「运行示例」后,左侧显示源码、右侧显示运行结果;console 输出会实时回传。
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>空白与换行</title>
<style>
body { margin: 0; padding: 32px; background: #f8fafc; color: #0f172a; font-family: system-ui, sans-serif; line-height: 1.75; }
h1 { margin: 0 0 16px; font-size: 28px; }
.box { max-width: 720px; margin-bottom: 16px; padding: 14px; border: 1px solid #e2e8f0; border-radius: 10px; background: #fff; }
h2 { margin: 0 0 6px; font-size: 15px; }
pre { margin: 0; padding: 10px; overflow-x: auto; background: #0f172a; color: #e2e8f0; border-radius: 8px; font-size: 12px; }
code { background: #f1f5f9; padding: 1px 4px; border-radius: 3px; font-family: ui-monospace, monospace; }
.wbr { max-width: 260px; word-break: normal; }
</style>
</head>
<body>
<h1>空白与换行</h1>
<div class="box">
<h2>普通段落:折叠</h2>
<p>这里 有多个空格
和换行,但只显示一个空格。</p>
</div>
<div class="box">
<h2>pre:保留</h2>
<pre>第一行
第二行缩进
第三行缩进</pre>
</div>
<div class="box">
<h2>wbr:建议换行点</h2>
<p class="wbr">verylongfilenamewithoutspaces<wbr />andanotherpart</p>
</div>
</body>
</html>