我目前运行的是Chrome 109版本,在www.example.com上显示支持@container
查询。尽管如此,我还是无法让它工作。我用错了吗?你们中有人能让它在浏览器中工作吗?caniuse.com it says that the @container
query is supported. Despite of this I cannot get it to work. Am I using it wrong? Are any of you getting it to work in your browsers?
.grid {
display: grid;
grid-template-columns: 1fr 2fr;
resize: horizontal;
overflow: hidden;
}
.col1 {
background-color: #ccc;
height: 150px;
}
.col2 {
background-color: #eee;
height: 150px;
container-type: inline-size;
}
@container (max-width: 150px) {
.grid {
background-color: red;
}
}
<div class='grid'>
<div class='col1'>1</div>
<div class='col2'>2</div>
</div>
1条答案
按热度按时间k97glaaz1#
对不起,我是用在线翻译用英语写的。可能是理解上的心理错误。我的意思是容器类型必须在父元素上指定。例如,像这样: