🗒️@container
container query,容器查询
用法
container-type: size | inline-size | normal;.post {
/* 声明包含上下文 */
container-type: inline-size;
}
/* 定义容器查询(基于具有包含上下文的最近祖先) */
@container (width < 700px) {
}<article class="post">
<section class="card">
<h2>Title</h2>
<p>xxx</p>
</section>
</article>.post {
/* 声明包含上下文 */
container-type: inline-size;
}
.post .card {
color: green;
}
/* 定义容器查询 */
@container (width < 700px) {
.post .card {
color: red;
}
}命名包含上下文
主要参考
Last updated