示例工程 09-lists

09-lists/demo-02-description/index.html

html · 1.8 KB

运行:描述列表

点击「运行示例」后,左侧显示源码、右侧显示运行结果;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; }
      dl { margin: 8px 0 0; }
      dt { margin-top: 8px; font-weight: 600; }
      dt:first-child { margin-top: 0; }
      dd { margin: 2px 0 0 0; color: #334155; }
      dd ul { margin: 4px 0 0; padding-left: 22px; }
      .note { color: #64748b; font-size: 13px; }
    </style>
  </head>
  <body>
    <h1>描述列表</h1>

    <div class="box">
      <h2>一个术语,一个解释</h2>
      <dl>
        <dt>HTML</dt>
        <dd>描述文档结构。</dd>
        <dt>CSS</dt>
        <dd>描述视觉样式。</dd>
        <dt>DOM</dt>
        <dd>浏览器解析后的文档对象模型。</dd>
      </dl>
    </div>

    <div class="box">
      <h2>一个术语,多个解释</h2>
      <dl>
        <dt>content model</dt>
        <dd>元素允许包含的子元素与文本。</dd>
        <dd>决定嵌套是否合法。</dd>
      </dl>
      <p class="note">一个 dt 后面可以跟多个 dd,读屏会依次播报。</p>
    </div>

    <div class="box">
      <h2>解释里可以放列表</h2>
      <dl>
        <dt>列表类型</dt>
        <dd>
          常见三种:
          <ul>
            <li>ul:无序</li>
            <li>ol:有序</li>
            <li>dl:描述</li>
          </ul>
        </dd>
      </dl>
    </div>
  </body>
</html>