<!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>骰子</title>
<style>
div{
width: 100px;
height: 100px;
background-color: gray;
border: 1px solid black;
float: left;
display: flex;
justify-content: space-between;
}
span{
width: 25px;
height: 25px;
background-color: black;
border-radius: 50%;
display: inline-block;
color: white;
text-align: center;
}
/* 1点 */
.one{
justify-content: center;
}
.one>span{
align-self: center;
}
/* 2点 */
.two>span:nth-of-type(2){
align-self: flex-end;
}
/* 3点 */
.three>span:nth-of-type(2){
align-self: center;
}
.three>span:nth-of-type(3){
align-self: flex-end;
}
/* 4点 */
.four{
flex-wrap: wrap;
}
.four>span:nth-of-type(3){
margin-right: 50px;
align-self: end;
}
.four>span:nth-of-type(4){
align-self: end;
}
/* 5点 */
.five{
flex-wrap: wrap;
align-content: space-between;
}
.five>span:nth-of-type(3){
margin: 0 37.5px;
}
/* 6点 */
.six{
flex-wrap: wrap;
align-content: space-between;
}
.six>span:nth-of-type(2){
margin: 0 12.5px;
}
</style>
</head>
<body>
<div class="one">
<span style="background-color: red;">1</span>
</div>
<div class="two">
<span>1</span>
<span>2</span>
</div>
<div class="three">
<span>1</span>
<span>2</span>
<span>3</span>
</div>
<div class="four">
<span>1</span>
<span>2</span>
<span>3</span>
<span>4</span>
</div>
<div class="five">
<span>1</span>
<span>2</span>
<span>3</span>
<span>4</span>
<span>5</span>
</div>
<div class="six">
<span>1</span>
<span>2</span>
<span>3</span>
<span>4</span>
<span>5</span>
<span>6</span>
</div>
</body>
</html>
弹性盒子应用:骰子
于 2022-07-13 18:33:55 首次发布