flex

2018-01-07  本文已影响0人  pawN_f294

弹性盒子布局 参考 阮一峰老师

兼容性


image
  • 设置为弹性盒子display: flex 要加上浏览器的前缀。
  • 设置为弹性盒子后,他的子元素被称为项目;

flex-direction :设置项目的排列方向 默认值 (左到右)

  • flex-direction: row 默认从左到右
  • flex-direction: row-reverse 从右排到左
  • flex-direction: column 从上排到下
  • flex-direction: column-reverse 从下排到上
image

flex-wrap: 设置项目的换行方式 默认 (不换行)

  • flex-wrap: nowrap 不换行
    PS: 不换行的情况下,盒子会尽量包含所有的项目,即使你设置了项目的宽度或高度,但你可以设置它的最小值,(min-width / min-height);
  • flex-wrap: wrap 换行
  • flex-wrap: reverse 换行,第一行在最后。

flex-flow : flex-direction属性和flex-wrap属性的简写形式,默认值为row nowrap。

flex-flow: row nowrap

justify-content (水平对齐方式)

justify-content: flex-start 左对齐
justify-content: flex-ent 右对齐
justify-content: center 居中对齐
justify-content: space-between 两端对齐
justify-content: space-around 平均对齐

image

align-items 项目单一行垂直对齐方式

flex-start 盒子顶端对齐
flex-end 盒子底端对齐
center 盒子垂直中线对齐
stretch 填满盒子高度
baseline: 基线对齐 (第一行文字)

image

align-content 项目多行垂直对齐方式

flex-start 盒子顶端对齐
flext-end 盒子底端对齐
center 盒子垂直中线对齐
stretch 拉升占满整个垂直盒子高度
space-between 两端对齐
pace-around 平均对齐

image

项目属性

image
上一篇下一篇

猜你喜欢

热点阅读