示例工程 47-naming-conventions

47-naming-conventions/demo-02-scope/index.html

html · 0.6 KB

运行:@scope 作用域

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

<!doctype html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>@scope 作用域</title>
    <link rel="stylesheet" href="style.css" />
  </head>
  <body>
    <h1>@scope 作用域</h1>
    <p>两个面板都有 .title,但颜色不同。</p>

    <div class="panel blue">
      <h2 class="title">蓝色标题</h2>
      <p>scope 内 .title 为蓝色。</p>
    </div>

    <div class="panel green">
      <h2 class="title">绿色标题</h2>
      <p>scope 内 .title 为绿色。</p>
    </div>

    <h2 class="title outside">外部标题</h2>
  </body>
</html>