示例工程 21-data-report
21-data-report/demo-01-summary/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.7; }
.box { max-width: 760px; 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 10px; color: #334155; }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 0; }
.metrics div { padding: 12px; border: 1px solid #e2e8f0; border-radius: 8px; }
.metrics dt { color: #64748b; font-size: 13px; }
.metrics dd { margin: 2px 0 0; font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
figure { margin: 0; }
img { display: block; width: 100%; height: auto; border-radius: 8px; }
figcaption { margin-top: 6px; color: #64748b; font-size: 13px; }
</style>
</head>
<body>
<h1>报告摘要</h1>
<div class="box">
<h2>四个关键指标</h2>
<dl class="metrics">
<div><dt>总访问量</dt><dd>45,000</dd></div>
<div><dt>总注册数</dt><dd>4,500</dd></div>
<div><dt>总转化数</dt><dd>1,350</dd></div>
<div><dt>整体转化率</dt><dd>3.0%</dd></div>
</dl>
</div>
<div class="box">
<h2>图表与文字替代</h2>
<figure>
<img src="assets/chart.svg" alt="季度访问量逐季上升,Q4 最高" width="720" height="360" loading="lazy" />
<figcaption>图 1:2026 年季度访问量。</figcaption>
</figure>
<p>读屏用户通过 alt 与图注理解趋势,精确值在数据表里。</p>
</div>
</body>
</html>