示例工程 23-container-queries
23-container-queries/demo-01-card-states/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>同一份卡片 HTML,三个不同宽度的容器。</p>
<div class="row">
<div class="host w-200">
<article class="card">
<div class="art" aria-hidden="true"></div>
<div class="body">
<h2>200px</h2>
<p>堆叠:图片在上,文字在下。</p>
</div>
</article>
</div>
<div class="host w-340">
<article class="card">
<div class="art" aria-hidden="true"></div>
<div class="body">
<h2>340px</h2>
<p>左右:图片固定,文字占剩余。</p>
</div>
</article>
</div>
<div class="host w-520">
<article class="card">
<div class="art" aria-hidden="true"></div>
<div class="body">
<h2>520px</h2>
<p>宽容器可以放更多内容。</p>
</div>
</article>
</div>
</div>
</body>
</html>