Flex布局中设置了容器留白均分,不能在设置项目居中
<div>
<a href="">
<span></span>
</a>
<a href="">
<span></span>
<span></span>
</a>
<a href="">
<span></span>
<span></span>
<span></span>
</a>
</div>
a {
display: flex;
margin-bottom: 20px;
position: relative;
left: 50%;
top: 200px;
width: 50px;
height: 50px;
background-color: aliceblue;
padding: 10px;
border-radius: 5px;
}
a span {
width: 12px;
height: 12px;
border-radius: 50%;
background-color: black;
}
a:nth-child(3) {
flex-direction: column;
}
a:nth-child(3) {
justify-content: space-evenly;
}
a:nth-child(3) span:nth-child(2) {
justify-content: center;
align-items: center;
background-color: aquamarine;
}
三个span主轴方向均匀排列,但是第二个不能去中间,第三个不能去最右
添加第二个span的背景颜色是变的,说明是主轴方向的位置属性冲突,但是自学css找不出原因
想做出类似骰子的三点样式。
<style>
div {
display: flex;
}
a {
display: flex;
margin-bottom: 20px;
/* position: relative; */
left: 50%;
top: 200px;
width: 50px;
height: 50px;
background-color: aliceblue;
padding: 10px;
border-radius: 5px;
}
a span {
width: 12px;
height: 12px;
border-radius: 50%;
background-color: black;
}
a:nth-child(3) {
flex-direction: column;
}
a:nth-child(3) {
justify-content: space-evenly;
}
a:nth-child(3) span:nth-child(2) {
justify-content: center;
align-items: center;
background-color: aquamarine;
}
</style>
<div>
<a href="">
<span></span>
</a>
<a href="">
<span></span>
<span></span>
</a>
<a href="">
<span></span>
<span></span>
<span></span>
</a>
</div>
<!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>Document</title>
<style>
a {
display: block;
margin-bottom: 20px;
/* position: relative;
left: 50%;
top: 200px; */
width: 50px;
height: 50px;
background-color: aliceblue;
padding: 10px;
border-radius: 5px;
}
a span {
display: block;
width: 12px;
height: 12px;
border-radius: 50%;
background-color: black;
}
.one, .two {
display: flex;
justify-content: space-around;
}
</style>
</head>
<body>
<div>
<a href="">
<span></span>
</a>
<a href="">
<span></span>
<span></span>
</a>
<a href="">
<div class="one">
<span></span>
</div>
<div class="two">
<span></span>
<span></span>
</div>
</a>
</div>
</body>
</html>
<!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>Document</title>
<style>
a {
display: flex;
align-items: center;
justify-content: space-evenly;
margin: 20px auto;
padding: 10px;
width: 50px;
height: 50px;
border-radius: 5px;
background-color: aliceblue;
}
a span {
width: 12px;
height: 12px;
border-radius: 50%;
background-color: black;
}
a:nth-child(3) span:nth-child(1){
align-self: flex-start;
}
a:nth-child(3) span:nth-child(2) {
background-color: aquamarine;
}
a:nth-child(3) span:nth-child(3){
align-self: flex-end;
}
</style>
</head>
<body>
<div>
<a href="">
<span></span>
</a>
<a href="">
<span></span>
<span></span>
</a>
<a href="">
<span></span>
<span></span>
<span></span>
</a>
</div>
</body>
</html>