flex布局

74 阅读1分钟

image.png

默认从左侧依次排列 justify-content: flex-start;

image.png

右侧依次排列 justify-content: flex-end;

image.png

居中对齐 justify-content: center;

image.png

每个盒子都有间隙,中间是两边的二倍 justify-content: space-around;

image.png

两侧没有间隙 justify-content: space-between;

image.png

盒子间隙一样大 justify-content: space-evenly;

image.png

image.png

盒子从顶部开始排列 align-items: flex-start;

image.png

盒子从底部开始排列 align-items: flex-end;

image.png

盒子垂直居中对齐 align-items: center;

image.png

拉伸 align-items: stretch;

image.png

注意事项:align-self属性是给弹性盒子设置(子级)


控制弹性盒子 align-self: center;

image.png

image.png 控制弹性盒子 align-self: flex-start; //顶部对齐 image.png 控制弹性盒子 align-self: flex-start; //底部对齐 image.png