示例工程 02-first-stylesheet

02-first-stylesheet/demo-02-minimal-reset/index.html

html · 1.6 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: 28px;
        background: #f8fafc;
        color: #0f172a;
        font-family: system-ui, sans-serif;
        line-height: 1.7;
      }

      .panels {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 16px;
        margin-top: 16px;
      }

      .panel {
        padding: 8px;
        border: 1px solid #e2e8f0;
        border-radius: 10px;
        background: #ffffff;
      }

      .panel h2 {
        margin-top: 0;
        font-size: 16px;
      }

      .reset * {
        margin: 0;
      }

      .reset ul {
        padding-left: 18px;
      }

      @media (max-width: 620px) {
        .panels {
          grid-template-columns: 1fr;
        }
      }
    </style>
  </head>
  <body>
    <h1>默认样式与最小重置</h1>
    <div class="panels">
      <section class="panel">
        <h2>默认</h2>
        <h3>标题有外边距</h3>
        <p>段落也有外边距,列表有默认缩进。</p>
        <ul>
          <li>第一项</li>
          <li>第二项</li>
        </ul>
      </section>
      <section class="panel reset">
        <h2>最小重置</h2>
        <h3>标题紧贴顶部</h3>
        <p>段落之间的间距由父容器控制。</p>
        <ul>
          <li>第一项</li>
          <li>第二项</li>
        </ul>
      </section>
    </div>
  </body>
</html>