示例工程 23-container-queries
23-container-queries/demo-02-units/style.css
点击「运行示例」后,左侧显示源码、右侧显示运行结果;console 输出会实时回传。
body {
margin: 0;
padding: 32px;
background: #f8fafc;
color: #0f172a;
font-family: system-ui, sans-serif;
line-height: 1.7;
}
h1 {
margin: 0 0 8px;
font-size: 26px;
}
.row {
display: flex;
flex-wrap: wrap;
gap: 16px;
margin-top: 18px;
}
.host {
container-type: inline-size;
}
.w-240 { width: 240px; }
.w-480 { width: 480px; }
.box {
padding: clamp(10px, 4cqw, 28px);
border-radius: 10px;
background: #2563eb;
color: #ffffff;
}
.box strong {
font-size: clamp(18px, 8cqw, 40px);
line-height: 1.2;
}
.box p {
margin: 6px 0 0;
font-size: clamp(12px, 3cqw, 16px);
}