<!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>
.parent {
width: 400px;
height: 200px;
background-color: green;
display: flex;
flex-wrap: wrap;
}
div {
/* 最终盒子之间间距为4px,边缘间距为2px,因为flex不会合并margin */
margin: 2px;
width: 196px;
height: 96px;
background-color: skyblue;
}
</style>
</head>
<body>
<div class="parent">
<div></div>
<div></div>
<div></div>
<div></div>
</div>
</body>
</html>
CSS flex布局换行
最新推荐文章于 2025-12-26 15:15:00 发布
355

被折叠的 条评论
为什么被折叠?



