示例工程 60-ship-and-review

60-ship-and-review/demo-02-budget/index.html

html · 1.2 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>用 --value 控制宽度,超过阈值换色。</p>

    <div class="budgets">
      <article class="budget">
        <div class="head"><span>LCP</span><strong>1.9s / 2.5s</strong></div>
        <div class="track"><span class="fill" style="--value: 76%"></span></div>
      </article>
      <article class="budget">
        <div class="head"><span>CLS</span><strong>0.04 / 0.1</strong></div>
        <div class="track"><span class="fill" style="--value: 40%"></span></div>
      </article>
      <article class="budget">
        <div class="head"><span>CSS</span><strong>42KB / 60KB</strong></div>
        <div class="track"><span class="fill" style="--value: 70%"></span></div>
      </article>
      <article class="budget">
        <div class="head"><span>超预算示例</span><strong>72KB / 60KB</strong></div>
        <div class="track"><span class="fill fill--over" style="--value: 100%"></span></div>
      </article>
    </div>
  </body>
</html>