示例工程 10-links
10-links/demo-01-relative-absolute/page-b.html
点击「运行示例」后,左侧显示源码、右侧显示运行结果;console 输出会实时回传。
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>页面 B</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; padding: 18px; border: 1px solid #e2e8f0; border-radius: 12px; background: #fff; }
h1 { margin: 0 0 12px; font-size: 28px; }
h2 { margin: 20px 0 8px; font-size: 17px; }
p { margin: 0 0 10px; color: #334155; }
a { color: #2563eb; }
</style>
</head>
<body>
<div class="box">
<h1>页面 B</h1>
<p><a href="index.html">返回演示首页</a></p>
<h2 id="details">细节</h2>
<p>从首页带 <code>#details</code> 跳转,会直接定位到这个小节。</p>
<p>锚点 id 在页面内唯一,改 id 会破坏已有链接。</p>
</div>
</body>
</html>