justify-content: 决定flex items 在主轴上的对齐方式
-
flex-start
-
flex-end
-
center
-
space-between
-
space-evenly
-
space-around
代码
<!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>
#box{
/* 开启flex布局:块元素 */
display: flex;
/* 开启flex布局;行元素 */
/* display: inline-flex; */
background-color: red;
600px;
/* 水平居中 */
margin: 0 auto;
/* flex-start: 默认值 main start对齐
flex-end: main end 对齐
center: 主轴中间对齐
space-between: 左右对齐等分主轴
space-around: 左右等分间隙然后等分
space-evenly: 左右窄,中间等分
*/
justify-content: space-around;
}
.item{
text-align: center;
line-height: 100px;
100px;
}
.item1{
background-color: azure;
}
.item2{
background-color: green;
}
.item3{
background-color: gold;
}
</style>
</head>
<body>
<div id="box">
<div class="item item1">item1</div>
<div class="item item2">item2</div>
<div class="item item3">item3</div>
</div>
<strong>行类元素</strong>
</body>
</html>