示例工程 17-gallery-page

17-gallery-page/demo-01-grid/index.html

html · 1.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>
      body { margin: 0; padding: 32px; background: #f8fafc; color: #0f172a; font-family: system-ui, sans-serif; line-height: 1.7; }
      h1 { margin: 0 0 8px; font-size: 28px; }
      p { margin: 0 0 18px; color: #334155; }
      .gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin: 0; padding: 0; list-style: none; }
      figure { margin: 0; padding: 10px; border: 1px solid #e2e8f0; border-radius: 10px; background: #fff; }
      img { display: block; width: 100%; height: auto; border-radius: 6px; }
      figcaption { margin-top: 6px; font-size: 13px; color: #475569; }
      a { color: #2563eb; }
    </style>
  </head>
  <body>
    <h1>图库网格</h1>
    <p>三张作品,用列表与 figure 组织。</p>

    <ul class="gallery">
      <li>
        <figure>
          <a href="assets/full-forest.svg"><img src="assets/forest.svg" alt="晨雾森林与远山" width="480" height="320" loading="lazy" /></a>
          <figcaption>晨雾森林 · 自然</figcaption>
        </figure>
      </li>
      <li>
        <figure>
          <a href="assets/full-coast.svg"><img src="assets/coast.svg" alt="海岸线与浅蓝海水" width="480" height="320" loading="lazy" /></a>
          <figcaption>海岸线 · 自然</figcaption>
        </figure>
      </li>
      <li>
        <figure>
          <a href="assets/full-city.svg"><img src="assets/city.svg" alt="夜晚城市天际线" width="480" height="320" loading="lazy" /></a>
          <figcaption>夜行城市 · 城市</figcaption>
        </figure>
      </li>
    </ul>
    <p><a href="assets/full-forest.svg">查看第一张大图</a></p>
  </body>
</html>