想说一下关于第5个骰子
先看一下一下错误代码
<div class="box5">
<div class="culmn5">
<div class="five"></div>
<div class="five"></div>
</div>
<div class="five center"></div>
<div class="culmn5">
<div class="five"></div>
<div class="five"></div>
</div>
</div>
.box5 {
display: flex;
height: 50px;
width: 50px;
background-color: #fff;
padding: 5px;
margin-left: 5px;
border-radius: 10px;
justify-content: space-between;
align-items: center;
}
.five {
background-color: black;
width: 15px;
height: 15px;
border-radius: 7.5px;
}
.center {
width: 17px;
height: 17px;
border-radius: 8.5px;
background-color: red;
/* align-self: center; */
}
.culmn5 {
display: flex;
flex-direction: column;
justify-content: space-between; /* 在这发现没法实现向两边分布 */
}
效果:
我最初的想法就是直接先让box5下面的的三个盒子直接上下左右居中,然后再调整左右两个小盒子culmn5的justify-content: space-between;(main cross此时被我改为culmn),但是没法实现,原因是
这俩个小黑点被限制在30px的范围之内了,所以我只能单独设置中间小红点的居中
items-self:center;
然后开启culmn5的flex布局
display: flex;
flex-direction: column;
justify-content: space-between;
最后贴出完整代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>flex</title>
<style>
.bigbox {
display: flex;
justify-content: center;
align-items: center;
width: 600px;
height: 600px;
background-color: orange;
margin: 0 auto;
}
.box1 {
height: 50px;
width: 50px;
background-color: #fff;
padding: 5px;
display: flex;
border-radius: 10px;
justify-content: center;
align-items: center;
}
.one {
background-color: red;
width: 18px;
height: 18px;
border-radius: 9px;
}
.box2 {
display: flex;
height: 50px;
width: 50px;
background-color: #fff;
padding: 5px;
margin-left: 5px;
border-radius: 10px;
justify-content: space-between;
}
.two1 {
background-color: black;
width: 15px;
height: 15px;
border-radius: 7.5px;
align-self: flex-start;
}
.two2 {
background-color: black;
width: 15px;
height: 15px;
border-radius: 7.5px;
align-self: flex-end;
}
.box3 {
display: flex;
height: 50px;
width: 50px;
background-color: #fff;
padding: 5px;
margin-left: 5px;
border-radius: 10px;
align-items: center;
justify-content: space-evenly;
}
.three {
background-color: black;
width: 12px;
height: 12px;
border-radius: 6px;
}
.three:nth-child(1) {
align-self: flex-start;
}
.three:nth-child(3) {
align-self: flex-end;
}
.box4 {
display: flex;
height: 50px;
width: 50px;
background-color: #fff;
padding: 5px;
margin-left: 5px;
border-radius: 10px;
justify-content: space-between;
}
.four {
background-color: black;
width: 15px;
height: 15px;
border-radius: 7.5px;
}
.culmn {
display: flex;
flex-direction: column;
justify-content: space-between;
}
.box5 {
display: flex;
height: 50px;
width: 50px;
background-color: #fff;
padding: 5px;
margin-left: 5px;
border-radius: 10px;
justify-content: space-between;
}
.five {
background-color: black;
width: 15px;
height: 15px;
border-radius: 7.5px;
}
.center {
width: 17px;
height: 17px;
border-radius: 8.5px;
background-color: red;
align-self: center;
}
.culmn5 {
display: flex;
flex-direction: column;
justify-content: space-between;
}
.box6 {
display: flex;
height: 50px;
width: 50px;
background-color: #fff;
padding: 5px;
margin-left: 5px;
border-radius: 10px;
justify-content: space-around;
}
.six {
background-color: black;
width: 15px;
height: 15px;
border-radius: 7.5px;
}
.culmn6 {
display: flex;
flex-direction: column;
justify-content: space-between;
}
</style>
</head>
<body>
<div class="bigbox">
<div class="box1">
<div class="one"></div>
</div>
<div class="box2">
<div class="two1"></div>
<div class="two2"></div>
</div>
<div class="box3">
<div class="three"></div>
<div class="three"></div>
<div class="three"></div>
</div>
<div class="box4">
<div class="culmn">
<div class="four"></div>
<div class="four"></div>
</div>
<div class="culmn">
<div class="four"></div>
<div class="four"></div>
</div>
</div>
<div class="box5">
<div class="culmn5">
<div class="five"></div>
<div class="five"></div>
</div>
<div class="five center"></div>
<div class="culmn5">
<div class="five"></div>
<div class="five"></div>
</div>
</div>
<div class="box6">
<div class="culmn6">
<div class="six"></div>
<div class="six"></div>
<div class="six"></div>
</div>
<div class="culmn6">
<div class="six"></div>
<div class="six"></div>
<div class="six"></div>
</div>
</div>
</div>
</body>
</html>