标签:flex 骰子 space content between display css justify
主要是利用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>
效果
标签:flex,骰子,space,content,between,display,css,justify 来源: https://www.cnblogs.com/loveliang/p/13722633.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。