示例工程 48-project-shell

48-project-shell/demo-01-layout/index.html

html · 2.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>
      * { box-sizing: border-box; }
      body { margin: 0; background: #f8fafc; color: #0f172a; font-family: system-ui, sans-serif; line-height: 1.7; }
      .skip { position: absolute; left: -9999px; top: 0; padding: 8px 12px; background: #2563eb; color: #fff; }
      .skip:focus { left: 8px; top: 8px; z-index: 20; }
      .site-header { border-bottom: 1px solid #e2e8f0; background: #fff; }
      .inner { display: flex; align-items: center; gap: 16px; max-width: 960px; margin: 0 auto; padding: 12px 20px; }
      .brand { font-weight: 700; }
      nav { display: flex; gap: 12px; margin-left: auto; font-size: 14px; }
      nav a { color: #2563eb; text-decoration: none; }
      .layout { display: grid; grid-template-columns: minmax(0, 1fr) 200px; gap: 24px; max-width: 960px; margin: 0 auto; padding: 20px; }
      main { min-width: 0; }
      h1 { margin: 0 0 8px; font-size: 28px; }
      p { margin: 0 0 10px; color: #334155; }
      .region { padding: 12px; border: 1px dashed #93c5fd; border-radius: 8px; background: #eff6ff; font-size: 13px; color: #1e3a8a; }
      aside { align-self: start; }
      aside .region { background: #f0fdf4; border-color: #86efac; color: #166534; }
      footer { margin-top: 20px; border-top: 1px solid #e2e8f0; background: #fff; }
      .foot { max-width: 960px; margin: 0 auto; padding: 12px 20px; color: #64748b; font-size: 12px; }
      h2 { margin: 18px 0 6px; font-size: 16px; }
      code { padding: 1px 5px; border-radius: 4px; background: #f1f5f9; font-family: ui-monospace, monospace; }
      @media (max-width: 720px) { .layout { grid-template-columns: 1fr; } .inner { flex-wrap: wrap; } }
    </style>
  </head>
  <body>
    <a class="skip" href="#main">跳到主内容</a>

    <header class="site-header">
      <div class="inner">
        <span class="brand">文档站</span>
        <nav aria-label="主导航">
          <a href="#guides">指南</a>
          <a href="#about">关于</a>
        </nav>
      </div>
    </header>

    <div class="layout">
      <main id="main">
        <h1>页面骨架</h1>
        <p>每一块对应一个语义地标,读屏可以按地标跳转。</p>

        <h2>header</h2>
        <div class="region">品牌 + 主导航 + 搜索,全站一致。</div>

        <h2>main</h2>
        <div class="region">每页唯一,包含 h1 与正文。</div>

        <h2>aside</h2>
        <div class="region">页内目录或相关链接,窄屏可隐藏。</div>
      </main>

      <aside aria-label="页内目录">
        <div class="region">aside:本页目录</div>
      </aside>
    </div>

    <footer>
      <div class="foot">footer:版权与辅助链接</div>
    </footer>
  </body>
</html>