示例工程 09-lists
09-lists/demo-01-unordered-ordered/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; }
.box { max-width: 720px; margin-bottom: 16px; padding: 18px; border: 1px solid #e2e8f0; border-radius: 12px; background: #fff; }
h1 { margin: 0 0 16px; font-size: 28px; }
h2 { margin: 0 0 8px; font-size: 17px; }
p { margin: 0 0 8px; color: #334155; }
ul, ol { margin: 8px 0 0; padding-left: 24px; color: #334155; }
li + li { margin-top: 4px; }
li > ul, li > ol { margin-top: 4px; }
.note { color: #64748b; font-size: 13px; }
</style>
</head>
<body>
<h1>无序与有序列表</h1>
<div class="box">
<h2>ul:没有先后</h2>
<ul>
<li>可访问性</li>
<li>性能</li>
<li>可维护性</li>
</ul>
<p class="note">调换顺序不影响意思,所以用 ul。</p>
</div>
<div class="box">
<h2>ol:有先后</h2>
<ol>
<li>备份数据</li>
<li>执行迁移</li>
<li>验证结果</li>
</ol>
<p class="note">顺序不能换,所以用 ol。</p>
</div>
<div class="box">
<h2>ol 的 start 与 reversed</h2>
<ol start="5">
<li>第五步</li>
<li>第六步</li>
</ol>
<ol reversed>
<li>先做最后一步</li>
<li>再做前一步</li>
</ol>
</div>
<div class="box">
<h2>嵌套:子列表放进 li</h2>
<ul>
<li>
前端
<ul>
<li>HTML</li>
<li>CSS</li>
</ul>
</li>
<li>
后端
<ul>
<li>Node.js</li>
</ul>
</li>
</ul>
</div>
</body>
</html>