CSS gap
属性是用来设置网格行与列之间的间隙(gutters),该属性是 row-gap
和 column-gap
的简写形式。 developer.mozilla.org/zh-CN/docs/...
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.box {
background: red;
display: flex;
flex-wrap: wrap;
padding: 10px;
row-gap: 10px;
}
.inner-box {
background: green;
width: 100px;
height: 100px;
border: 1px solid yellow;
}
</style>
</head>
<body>
<div class="box">
<div class="inner-box"></div>
<div class="inner-box"></div>
<div class="inner-box"></div>
<div class="inner-box"></div>
<div class="inner-box"></div>
<div class="inner-box"></div>
<div class="inner-box"></div>
<div class="inner-box"></div>
<div class="inner-box"></div>
<div class="inner-box"></div>
<div class="inner-box"></div>
<div class="inner-box"></div>
</div>
</body>
</html>
row-gap
css
.box {
background: red;
display: flex;
flex-wrap: wrap;
padding: 10px;
row-gap: 10px;
}
column-gap
css
.box {
background: red;
display: flex;
flex-wrap: wrap;
padding: 10px;
row-gap: 10px;
column-gap: 10px;
}