示例工程 30-tables-lists

30-tables-lists/demo-01-table/index.html

html · 1.3 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>
    <link rel="stylesheet" href="style.css" />
  </head>
  <body>
    <h1>表格的可读性</h1>
    <p>表头粘住、斑马纹、数字右对齐;滚动表格看表头。</p>

    <div class="wrap">
      <table>
        <caption>2026 年季度数据(示例)</caption>
        <thead>
          <tr>
            <th scope="col">季度</th>
            <th scope="col" class="num">访问</th>
            <th scope="col" class="num">转化率</th>
          </tr>
        </thead>
        <tbody>
          <tr><th scope="row">Q1</th><td class="num">12,400</td><td class="num">3.8%</td></tr>
          <tr><th scope="row">Q2</th><td class="num">15,240</td><td class="num">4.1%</td></tr>
          <tr><th scope="row">Q3</th><td class="num">18,390</td><td class="num">4.4%</td></tr>
          <tr><th scope="row">Q4</th><td class="num">21,860</td><td class="num">4.9%</td></tr>
          <tr><th scope="row">合计</th><td class="num">67,890</td><td class="num">4.3%</td></tr>
          <tr><th scope="row">同比</th><td class="num">+12.4%</td><td class="num">+0.6pt</td></tr>
        </tbody>
      </table>
    </div>
  </body>
</html>