<!DOCTYPE html
>
<
html
lang=
"en"
>
<
head
>
<
meta
charset=
"UTF-8"
>
<
meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<
meta
http-equiv=
"X-UA-Compatible"
content=
"ie=edge"
>
<
meta
name=
"viewport"
content=
"width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scale=0"
/>
<
title
>Document
</
title
>
<
style
>
.box{
width:
500px;
height:
500px;
margin:
50px
auto;
/* 设置flex布局方式 */
display:
flex;
border:
1px
solid
green ;
/* 设置左对齐: justify-content是指x方向 */
/* justify-content:flex-start; */
/* 右对齐 */
/* justify-content:flex-end; */
/* 居中对齐 */
/* justify-content:center; */
/* 均匀分布:space-around 两端对齐;space-between */
/* align-items:y方向上,参数和x一样 */
/* 拉伸布局:会自动撑满容器 不可以设置高度,否则没有效果*/
/* align-items: stretch */
}
.box>
div{
width:
100px;
height:
100px;
font-size:
80px;
line-height:
100px;
text-align:
center;
}
.box>
div:nth-child(
1
){
background-color:
antiquewhite;
/* 1:flex-grow:放大比例,就是当父盒子有空余,没有被填满,该添加这个属性的盒子被放大
2:flex-shrink:缩小比例,空间不足被调用
3.flex-basis:设置固定值的大小*/
/* flex-grow:1; */
/* 三个参数:放大 缩小 固定值 */
/* flex: 1 1 50px; */
}
.box>
div:nth-child(
2
){
background-color:
rgb(
103,
13,
163);
/* 设置单独的位置 设置Y轴 */
align-self:
flex-end
}
.box>
div:nth-child(
3
){
background-color:
rgb(
202,
20,
105)
}
.box>
div:nth-child(
4
){
background-color:
rgb(
17,
182,
30)
}
.box>
div:nth-child(
5
){
background-color:
rgb(
72,
80,
70)
}
<
/
style
>
</
head
>
<
body
>
<
div
class=
"box"
>
<
div
>1
</
div
>
<
div
>2
</
div
>
<
div
>3
</
div
>
<
div
>4
</
div
>
<
div
>5
</
div
>
</
div
>
</
body
>
</
html
>