一、效果
二、代码
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>justify-content属性</title>
<style>
.x {
width: 1000px;
height: 300px;
border: 2px solid pink;
margin: 100px auto;
display: flex;
justify-content: space-around;
}
.x>div {
width: 250px;
height: 100%;
}
.x>div:first-child {
background-color: pink;
}
.x>div:nth-child(2) {
background-color: purple;
}
.x>div:nth-child(3) {
background-color: skyblue;
}
.y {
width: 1000px;
height: 600px;
border: 2px solid pink;
margin: 100px auto;
display: flex;
justify-content: space-around;
align-items: stretch;
}
.y>div {
width: 250px;
}
.y>div:first-child {
background-color: pink;
}
.y>div:nth-child(2) {
background-color: purple;
}
.y>div:nth-child(3) {
background-color: skyblue;
}
.wrap {
width: 1000px;
height: 200px;
border: 2px solid pink;
margin: 100px auto;
display: flex;
flex-wrap: wrap;
}
.wrap>div {
width: 250px;
height: 200px;
}
.wrap>div:first-child {
background-color: pink;
}
.wrap>div:nth-child(2) {
background-color: purple;
}
.wrap>div:nth-child(3) {
background-color: skyblue;
}
.wrap>div:nth-child(4) {
background-color: hotpink;
order: -1;
}
.wrap>div:nth-child(5) {
background-color: deeppink;
}
</style>
</head>
<body>
<section class="x">
<div>1</div>
<div>2</div>
<div>3</div>
</section>
<hr />
<section class="y">
<div>1</div>
<div>2</div>
<div>3</div>
</section>
<hr />
<section class="wrap">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
</section>
</body>
</html>