主要是利用flex的一些特性来写的,掌握好flex基础,写出筛子的几个页面不是问题。
推荐去我写的一个博客中有flex的小练习 线上练习flex布局
html
<body>
<div class="shaizi">
<div class="top">
<div class="Box1 Box">
<span class="item"></span>
</div>
<div class="Box2 Box">
<span class="item"></span>
<span class="item"></span>
</div>
<div class="Box3 Box">
<span class="item"></span>
<span class="item"></span>
<span class="item"></span>
</div>
</div>
<div class="bottom">
<div class="Box4 Box">
<div class="Box4_top">
<span class="item"></span>
<span class="item"></span>
</div>
<div class="Box4_buttom">
<span class="item"></span>
<span class="item"></span>
</div>
</div>
<div class="Box5 Box">
<div class="Box5_top">
<span class="item"></span>
<span class="item"></span>
</div>
<div class="Box5_center">
<span class="item"></span>
</div>
<div class="Box5_buttom">
<span class="item"></span>
<span class="item"></span>
</div>
</div>
<div class="Box6 Box">
<div class="Box6_top">
<span class="item"></span>
<span class="item"></span>
</div>
<div class="Box6_center">
<span class="item"></span>
<span class="item"></span>
</div>
<div class="Box6_buttom">
<span class="item"></span>
<span class="item"></span>
</div>
</div>
</div>
</div>
</body>
css
<style>
.shaizi {
width: 1400px;
height: 600px;
margin: auto;
border: 2px solid #ddd;
border-radius: 10px;
padding: 20px;
display: flex;
flex-wrap: wrap;
/* flex-direction: column;; */
}
.item {
display: block;
width: 40px;
height: 40px;
border-radius: 50%;
background-color: #666;
}
.Box{
width: 200px;
height: 200px;
border: 2px solid #ccc;
border-radius: 10px;
padding: 20px;
display: flex;
}
.top {
display: flex;
width: 1400px;
justify-content: space-around;
}
.bottom{
display: flex;
width: 1400px;
justify-content: space-around;
}
.Box1 {
justify-content: center;
align-items: center;
}
.Box2 {
justify-content: space-between;
align-items: center;
}
.Box3 {
justify-content: space-between;
/* 两端对齐 */
}
.Box3 .item:nth-child(2) {
align-self: center;
/* 上下左右居中对齐 */
}
.Box3 .item:nth-child(3) {
align-self: flex-end;
/* 尾对齐 */
}
.Box4 {
flex-direction: column;
justify-content: space-between;
}
.Box4_top{
width: 200px;
height: 100px;
display: flex;
justify-content: space-between;
align-items: center;
}
.Box4_buttom{
width: 200px;
height: 100px;
display: flex;
justify-content: space-between;
align-items: center;
}
.Box5{
flex-direction: column;
justify-content: space-between;
}
.Box5_top{
display: flex;
justify-content: space-between;
}
.Box5_center{
display: flex;
justify-content: center;
}
.Box5_buttom{
display: flex;
justify-content: space-between;
}
.Box6{
flex-direction: column;
justify-content: space-between;
}
.Box6_top{
display: flex;
justify-content: space-between;
}
.Box6_center{
display: flex;
justify-content: space-between;
}
.Box6_buttom{
display: flex;
justify-content: space-between;
}
</style>
效果
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。