示例工程 32-states-focus

32-states-focus/demo-01-states/index.html

html · 1.1 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>
    <link rel="stylesheet" href="style.css" />
  </head>
  <body>
    <h1>状态矩阵</h1>
    <p>左边是真实按钮,右边是预览类;视觉应一致。</p>

    <div class="row">
      <button class="btn" type="button">默认</button>
      <button class="btn is-hover" type="button">is-hover</button>
      <button class="btn is-active" type="button">is-active</button>
      <button class="btn is-focus" type="button">is-focus</button>
      <button class="btn" type="button" disabled>disabled</button>
    </div>

    <div class="row">
      <button class="btn primary" type="button">主按钮(可交互)</button>
    </div>

    <pre><code>.btn:hover { background: var(--state-hover); }
.btn:active { background: var(--state-active); }
.btn:focus-visible { outline: 2px solid var(--state-focus); }
.btn:disabled { background: var(--state-disabled); }</code></pre>
  </body>
</html>