3 回答
TA贡献1877条经验 获得超1个赞
您可以将两个组合grid-box到另一个中div并获得所需的输出。`
<div class="content">
<div class="content">
<div class="grid-box">
<div class="grid-box-icon"><i class="fa fa-hands-wash"></i></div>
<h2>Wash your hands</h2>
</div>
<div class="grid-box">
<div class="grid-box-icon"><i class="fa fa-head-side-mask"></i></div>
<h2>Cover your face</h2>
</div>
</div>
<div class="content">
<div class="grid-box">
<div class="grid-box-icon"><i class="fa fa-people-arrows"></i></div>
<h2>Social distance</h2>
</div>
<div class="grid-box">
<div class="grid-box-icon"><i class="fa fa-spray-can"></i></div>
<h2>Sanitize common items</h2>
</div>
</div>
</div>
TA贡献1831条经验 获得超9个赞
不带 mediaquerie 的 Flex 也可以是这里的一个选项,因为没有元素可以跨越行或列。
将元素包装在 1、2 或 4 行中的想法示例:
body {
margin: 0;
}
.content {
display: flex;
flex-wrap: wrap;
}
.grid-box {
margin: 10pt;
padding: 20pt 10pt 0pt 20pt;
text-align: center;
background-color: rgba(204, 221, 204, .6);
border-radius: 30px;
border: 1px solid black;
flex: 1;
min-width: 350px;
min-height: calc(50vh - 40pt);
}
.grid-box {/* optionnal, for the demo */
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css" rel="stylesheet" />
<div class="content">
<div class="grid-box">
<div class="grid-box-icon"><i class="fa fa-hands-wash"></i></div>
<h2>Wash your hands</h2>
</div>
<div class="grid-box">
<div class="grid-box-icon"><i class="fa fa-head-side-mask"></i></div>
<h2>Cover your face</h2>
</div>
<div class="grid-box">
<div class="grid-box-icon"><i class="fa fa-people-arrows"></i></div>
<h2>Social distance</h2>
</div>
<div class="grid-box">
<div class="grid-box-icon"><i class="fa fa-spray-can"></i></div>
<h2>Sanitize common items</h2>
</div>
</div>
TA贡献1811条经验 获得超5个赞
您可以简单地将每两个 div 放入一个,如下所示:https ://codepen.io/Aypro18/pen/OJyMVMq?editors=1100
CSS:
.content {
display: grid;
grid-template-columns: repeat( auto-fit, minmax(300px, 1fr) );
min-height: calc(50vh - 20pt);
}
.grid-container{
display: grid;
grid-template-columns: repeat( auto-fit, minmax(300px, 1fr) );
min-height: calc(50vh - 20pt);
}
.grid-box {
margin: 10pt;
padding: 20pt 10pt 0pt 20pt;
text-align: center;
background-color: rgba($color: #ccddcc, $alpha: 0.6);
border-radius: 30px;
border: 1px solid black;
flex: 1 0 34%;
}
HTML:
<div class="content">
<div class="grid-container">
<div class="grid-box">
<div class="grid-box-icon"><i class="fa fa-hands-wash"></i></div>
<h2>Wash your hands</h2>
</div>
<div class="grid-box">
<div class="grid-box-icon"><i class="fa fa-head-side-mask"></i></div>
<h2>Cover your face</h2>
</div>
</div>
<div class="grid-container">
<div class="grid-box">
<div class="grid-box-icon"><i class="fa fa-people-arrows"></i></div>
<h2>Social distance</h2>
</div>
<div class="grid-box">
<div class="grid-box-icon"><i class="fa fa-spray-can"></i></div>
<h2>Sanitize common items</h2>
</div>
</div>
</div>
- 3 回答
- 0 关注
- 136 浏览
添加回答
举报