示例工程 21-media-queries
21-media-queries/demo-02-preferences/index.html
点击「运行示例」后,左侧显示源码、右侧显示运行结果;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>
<section class="card scheme">
<h2>prefers-color-scheme</h2>
<p>在深色系统下,这张卡片会变成深色。</p>
</section>
<section class="card">
<h2>prefers-reduced-motion</h2>
<div class="motion">
<span class="dot" aria-hidden="true"></span>
<span>开启「减少动态效果」后,圆点停止脉动。</span>
</div>
</section>
<section class="card">
<h2>hover / pointer</h2>
<p class="hover-yes">检测到悬停能力:可以显示 hover 状态。</p>
<p class="hover-no">没有悬停能力:操作要直接可点。</p>
</section>
</body>
</html>