<!--
flex-direction
row(默认值):主轴为水平方向,起点在左端。
row-reverse:主轴为水平方向,起点在右端。
column:主轴为垂直方向,起点在上沿。
column-reverse:主轴为垂直方向,起点在下沿。
justify-content
flex-start(默认值):与main start对齐
flex-end:与main end对齐
center:居中
space-between:flex items 之间的距离相等,与main start、main end两端对齐
space-evenly: flex items 之间的距离相等,flex items与main start 、main end 之间的距离等于flex items之间的距离
space-around :flex items 之间的距离相等,flex items与main start 、main end 之间的距离等于flex items之间的距离的一半
align-items
决定flex items在cross axis上的对齐方式
normal:在弹性布局中,效果和stretch一样
stretch:前提是items不设置高度,当flex items 在cross axis 方向的size为auto时,会自动拉伸至填充flex container(或者换句话说:如果项目未设置高度或设为auto,将占满整个容器的高度。)
flex-satrt:与cross start 对齐
flex-end:与cross end 对齐
center:居中对齐
baseline:与基准线对齐
align-content
决定了多行flex items 在cross axis的对齐方式 用法与justify-content相似 一个是横轴。一个控制竖轴
stretch(默认值):与align-items的stretch类似,当items有高度的时候,无效果
flex-start:与cross start 对齐
flex-end :与cross end 对齐
center:居中对齐
space-between:flex items 之间的距离相等,与cross start、cross end两端对齐
space-evently: flex items 之间的距离相等,flex items与cross start 、cross end 之间的距离等于flex items之间的距离
space-around :flex items 之间的距离相等,flex items与cross start 、cross end 之间的距离等于flex items之间的距离的一半
-->
<!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>
#container{background-color: yellow;width: 600px;height: 500px;
display: flex;justify-content: space-evenly;align-items: center;}
.item{width: 100px;height: 100px;background-color: red;}
span{width: 20px;height: 20px;border-radius: 50%;background-color: black;}
.one{display: flex;justify-content: center;align-items: center;}
.item-one{display: flex;justify-content: space-between;}
.one_two{align-self: center;}
.one_three{align-self: flex-end;}
.item-two{display: flex;justify-content: space-around;}
.three_one , .three_three{
display: flex;flex-direction: column;justify-content: space-between;
}
.three_two{display: flex;flex-direction: column;justify-content: center;}
.item-three{display: flex;justify-content: space-around;}
#four , #four2{display: flex;flex-direction: column;justify-content: space-between;}
</style>
</head>
<body>
<div id="container">
<section class="item one">
<span></span>
</section>
<section class=" item item-one">
<span></span>
<span class="one_two"></span>
<span class="one_three"></span>
</section>
<section class=" item item-two">
<div class="three_one">
<span></span>
<span></span>
</div>
<div class="three_two">
<span></span>
</div>
<div class="three_three">
<span></span>
<span></span>
</div>
</section>
<section class=" item item-three">
<div id="four">
<span></span>
<span></span>
<span></span>
</div>
<div id="four2">
<span></span>
<span></span>
<span></span>
</div>
</section>
</div>
</body>
</html>