flex布局

51 阅读1分钟

flex-direction

  • row

image.png

  • row-reverse

image.png

  • column

image.png

  • column-reverse

image.png

justify-content

  • start

image.png

  • end

image.png

  • center

image.png

  • space-between

image.png

image.png

  • space-around

image.png

image.png

  • space-evenly (所有间隔相等,包含容器)

image.png

align-items

  • flex-start

image.png

  • flex-end

image.png

  • center

image.png

  • stretch(未给子元素设置高度,将撑满容器) image.png

  • stretch (给子元素设置了高度,则按照设置高度展示) image.png

flex-wrap

  • wrap

image.png

  • nowrap

image.png

  • wrap-reverse

image.png

align-content

  • flex-start

image.png

  • flex-end

image.png

  • center

image.png

  • stretch (子元素未设置高度)

image.png

  • stretch (子元素已设置高度)

image.png

  • space-between

image.png

  • space-around

image.png

子元素属性

  • order: 定义子元素的排序

  • align-self: 子元素自身的align属性

  • flex: flex-grow 、flex-shrink、flex-basis简写

flex-grow:按容器剩余空间的比例方法元素,将容器填充满,默认值为1 flex-shrink:按照被挤压空间的比例缩小元素 默认值为1 flex-basis:元素初始大小,默认auto