示例工程 46-progressive-enhancement

46-progressive-enhancement/demo-01-baseline/index.html

html · 2.6 KB

运行:纯 HTML 基线演示

点击「运行示例」后,左侧显示源码、右侧显示运行结果;console 输出会实时回传。

<!doctype html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>纯 HTML 基线演示</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; }
      form { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
      label { font-size: 13px; font-weight: 600; }
      input[type="search"] { padding: 6px 9px; border: 1px solid #cbd5e1; border-radius: 6px; font: inherit; }
      button { padding: 6px 12px; border: 1px solid #2563eb; border-radius: 6px; background: #2563eb; color: #fff; font: inherit; }
      ul { margin: 10px 0 0; padding-left: 22px; color: #334155; }
      details { margin-top: 10px; padding: 10px 12px; border: 1px solid #e2e8f0; border-radius: 8px; background: #f8fafc; }
      summary { cursor: pointer; font-weight: 600; }
      .tag { display: inline-block; padding: 0 6px; border-radius: 4px; background: #e0f2fe; color: #075985; font-size: 12px; }
      code { padding: 1px 5px; border-radius: 4px; background: #f1f5f9; font-family: ui-monospace, monospace; }
    </style>
  </head>
  <body>
    <h1>纯 HTML 基线</h1>
    <p>本页没有任何 JavaScript。阅读、展开、提交表单全部由浏览器原生完成。</p>

    <div class="box">
      <h2>原生折叠</h2>
      <details open>
        <summary>为什么先用 HTML</summary>
        <p>HTML 已经能表达内容与基本交互,脚本只是加速器。</p>
      </details>
      <details>
        <summary>没有脚本时缺什么</summary>
        <p>缺少即时反馈、局部更新与复杂校验;核心任务仍能完成。</p>
      </details>
    </div>

    <div class="box">
      <h2>原生表单</h2>
      <p>提交后由服务端处理 <code>q</code> 参数。</p>
      <form method="get" action="#result">
        <div>
          <label for="q">关键词</label><br />
          <input id="q" name="q" type="search" placeholder="例如:文档" />
        </div>
        <button type="submit">筛选</button>
      </form>
      <ul>
        <li>发布文档 <span class="tag">待处理</span></li>
        <li>检查构建 <span class="tag">已完成</span></li>
        <li>更新截图 <span class="tag">待处理</span></li>
      </ul>
    </div>
  </body>
</html>