示例工程 28-buttons-dialog

28-buttons-dialog/demo-01-buttons/index.html

html · 2.0 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; }
      .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; }
      button { margin: 0 8px 8px 0; padding: 7px 14px; border: 1px solid #2563eb; border-radius: 6px; background: #2563eb; color: #fff; font: inherit; }
      button.secondary { background: #fff; color: #334155; border-color: #cbd5e1; }
      button:disabled { opacity: 0.55; }
      a { color: #2563eb; }
      code { padding: 1px 5px; border-radius: 4px; background: #f1f5f9; font-family: ui-monospace, monospace; }
    </style>
  </head>
  <body>
    <h1>按钮演示</h1>

    <div class="box">
      <h2>表单内按钮</h2>
      <form action="preview.html" method="post">
        <button type="submit">提交</button>
        <button type="button" class="secondary">普通按钮</button>
        <button type="reset" class="secondary">重置</button>
        <button type="submit" formaction="draft.html" class="secondary">保存草稿</button>
      </form>
      <p>不写 type 时,表单内按钮默认 submit。</p>
    </div>

    <div class="box">
      <h2>按钮与链接</h2>
      <p><a href="preview.html">跳转到预览页</a> 是链接。</p>
      <p><button type="button">打开菜单</button> 是动作。</p>
      <p>不要用 <code>a href="#"</code> 当按钮。</p>
    </div>

    <div class="box">
      <h2>禁用</h2>
      <button type="button" disabled>不可用</button>
      <p>禁用按钮不可聚焦、不提交,要说明原因。</p>
    </div>
  </body>
</html>