flex布局实现骰子的六个面
<!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>flex骰子</title>
<style>
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
.touzi{
margin: 100px auto;
width: 1000px;
height: 150px;
display: flex;
justify-content: space-between
}
/* 面 */
.box{
display: flex;
padding: 10px;
width: 150px;
height: 150px;
background-color: #e7e7e7;
border-radius: 10px;
box-shadow: inset 0 5px white,inset 0 -5px #bbb,inset 5px 0 #d7d7d7,inset -5px 0 #d7d7d7;
}
/* 点 */
span{
display: inline-block;
width: 30px;
height: 30px;
border-radius: 50%;
background-color: black;
box-shadow: inset 0 -2px #bbb;
}
/* 点数1 */
.one{
justify-content: center;
align-items: center;
}
/* 点数2 */
.two{
justify-content: space-between;
}
.two span:last-child{
align-self: flex-end;
}
/* 点数3 */
.three{
justify-content: space-between;
}
.three span:nth-child(2){
align-self: center;
}
.three span:last-child{
align-self: flex-end;
}
/* 点数4 */
.four{
flex-direction: column;
justify-content: space-between;
}
.four div{
display: flex;
justify-content: space-between;
}
/* 点数5 */
.five{
flex-direction: column;
justify-content: space-between;
}
.five div{
display: flex;
justify-content: space-between;
}
.center{
align-self: center;
}
/* 点数6 */
.six{
flex-direction: column;
justify-content: space-between;
}
.six div{
display: flex;
justify-content: space-between;
}
</style>
</head>
<body>
<div class="touzi">
<div class="box one">
<span></span>
</div>
<div class="box two">
<span></span><span></span>
</div>
<div class="box three">
<span></span><span></span><span></span>
</div>
<div class="box four">
<div>
<span></span><span></span>
</div>
<div>
<span></span><span></span>
</div>
</div>
<div class="box five">
<div>
<span></span><span></span>
</div>
<span class="center"></span>
<div>
<span></span><span></span>
</div>
</div>
<div class="box six">
<div>
<span></span><span></span>
</div>
<div>
<span></span><span></span>
</div>
<div>
<span></span><span></span>
</div>
</div>
</div>
</body>
</html>