示例工程 38-screen-reader
38-screen-reader/demo-02-announcements/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: 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 10px; color: #334155; }
label { display: block; margin: 6px 0 4px; font-size: 14px; }
input { width: 100%; max-width: 340px; padding: 7px 9px; border: 1px solid #cbd5e1; border-radius: 6px; font: inherit; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
caption { padding: 6px 8px; text-align: left; color: #475569; font-size: 13px; }
th, td { padding: 8px 10px; border-bottom: 1px solid #e2e8f0; text-align: left; }
thead th { background: #f1f5f9; }
.error { margin: 4px 0 0; color: #b91c1c; font-size: 13px; }
.status { margin-top: 10px; padding: 8px 10px; border-left: 4px solid #16a34a; background: #f0fdf4; color: #14532d; }
code { padding: 1px 5px; border-radius: 4px; background: #f1f5f9; font-family: ui-monospace, monospace; }
</style>
</head>
<body>
<h1>读屏播报</h1>
<div class="box">
<h2>表单</h2>
<label for="email">邮箱</label>
<input id="email" name="email" type="email" aria-invalid="true" aria-describedby="error" />
<p class="error" id="error">请输入有效的邮箱地址。</p>
<p class="status" role="status" aria-live="polite">草稿已保存</p>
<p>读屏会读标签、错误与状态。</p>
</div>
<div class="box">
<h2>表格</h2>
<table>
<caption>季度访问量</caption>
<thead><tr><th scope="col">季度</th><th scope="col">访问量</th></tr></thead>
<tbody>
<tr><th scope="row">Q1</th><td>1200</td></tr>
<tr><th scope="row">Q2</th><td>1500</td></tr>
</tbody>
</table>
<p>读屏会读表格名称、行名与列名。</p>
</div>
</body>
</html>