flex弹性布局

//布局格式

1.基础的左对齐:只需要父元素设置flex属性即可 排列由左往右排

.box {
  display: flex;
}
image.png

2.设置项目的对齐方式,就能实现居中对齐 justify-content 控制X轴方向的位置

.box {
  display: flex;
  justify-content: center;
}
image.png

3.设置项目的对齐方式,就能实现居右对起

.box {
  display: flex;
  justify-content: flex-end;
}
image.png

4.设置交叉轴对齐方式,可以垂直移动主轴。

.box {
  display: flex;
  align-items: center;
}
image.png
.box {
  display: flex;
  justify-content: center;
  align-items: center;
}
image.png
.box {
  display: flex;
  justify-content: center;
  align-items: flex-end;
}
image.png
.box {
  display: flex;
  justify-content: flex-end;
  align-items: flex-end;
}
image.png
.box {
  display: flex;
  justify-content: space-between;
}
image.png
.box {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
image.png
.box {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
}
image.png
.box {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-end;
}
image.png
.box {
  display: flex;
}

.item:nth-child(2) {
  align-self: center;
}
image.png
.box {
  display: flex;
  justify-content: space-between;
}

.item:nth-child(2) {
  align-self: flex-end;
}
image.png
.box {
  display: flex;
}

.item:nth-child(2) {
  align-self: center;
}

.item:nth-child(3) {
  align-self: flex-end;
}
image.png
.box {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-content: space-between;
}
image.png
.box { display: flex; flex-wrap: wrap; align-content: space-between; } .column { flex-basis: 100%; display: flex; justify-content: space-between; }
image.png
.box { display: flex; flex-wrap: wrap; } .row{ flex-basis: 100%; display:flex; } .row:nth-child(2){ justify-content: center; } .row:nth-child(3){ justify-content: space-between; }

`

你可能感兴趣的:(flex弹性布局)