[CSS] container queries (容器查询)
Browser support: https://caniuse.com/css-container-queries
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
.wrapper1 {
container-type: inline-size;
width: 100%;
border: 1px solid #ccc;
}
.box1 {
background: pink;
padding: 1rem;
}
@container (min-width: 700px) {
.box1 {
background: lightgreen;
}
}
</style>
</head>
<body>
<h2>container queries (容器查询)</h2>
<div class="wrapper1">
<div class="box1">我是一段文字1</div>
</div>
</body>
</html>