- flex-flow: 设置主轴的方向和项目在主轴的换行方式
- justify-content: 项目在主轴的对齐方式
- align-items: 项目在交叉轴上的对齐方式
- align-content: 设置项目在多行容器中的对齐方式
代码实例:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>实例演示:flex容器常用的四个属性</title>
<style>
* {
box-sizing: border-box;
}
.container {
height: 15em;
border: 1px solid coral;
padding: 1em;
margin: 1em;
display: flex;
}
.container > .item {
width: 8em;
background-color: lightyellow;
border: 1px solid chocolate;
}
.container {
flex-flow: row nowrap;
flex-flow: row wrap;
}
/* .container {
flex-flow: column nowrap;
flex-flow: column wrap;
flex-flow: column wrap-reverse;
height: 8em;
} */
.container {
justify-content: flex-start;
justify-content: flex-end;
justify-content: flex-end;
justify-content: center;
justify-content: space-between;
justify-content: space-around;
justify-content: space-evenly;
}
.container {
flex-flow: row nowrap;
align-items: stretch;
align-items: flex-start;
align-items: flex-end;
align-items: center;
}
/.container {
flex-flow: row wrap;
align-content: stretch;
align-content: flex-end;
align-content: flex-start;
align-content: center;
align-content: space-around;
align-content: space-between;
align-content: space-evenly;
}
</style>
</head>
<body>
<div class="container">
<div class="item">item1</div>
<div class="item">item2</div>
<div class="item">item3</div>
<div class="item">item4</div>
<div class="item">item5</div>
<div class="item">item6</div>
<div class="item">item7</div>
<div class="item">item8</div>
</div>
</body>
</html>