示例工程 02-first-stylesheet

02-first-stylesheet/demo-01-three-ways/index.html

html · 0.8 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" />
    <style>
      .internal {
        border-color: #16a34a;
        background: #f0fdf4;
        color: #166534;
      }
    </style>
  </head>
  <body>
    <h1>三种引入方式</h1>
    <p>三个方框使用同样的类名基础,但样式来源不同。</p>
    <div class="box external">外部样式表</div>
    <div class="box internal">内部 &lt;style&gt;</div>
    <div class="box inline" style="border-color: #dc2626; background: #fef2f2; color: #991b1b">
      行内 style
    </div>
    <p class="hint">行内样式优先级最高;内部与外部的顺序决定谁覆盖谁。</p>
  </body>
</html>