Flexbox - fantasy0107/notes GitHub Wiki

Flex Box

flex container

Properties for the Parent

container

display

定義為 flexbox

.container {
  display: flex; /* or inline-flex */
}

flex-direction

flexbox 的方向

.container {
  flex-direction: row(預設) | row-reverse | column | column-reverse;
}

flex-wrap

預設是同一列或行但如果想要改變就用這個

.container{
  flex-wrap: nowrap(預設) | wrap | wrap-reverse;
}

flex-flow

縮寫 flex-direction 和 flex-wrap

flex-flow: <‘flex-direction’> || <‘flex-wrap’>
預設是 row nowrap

justify-content

排列 flex items 的主要象限方法

.container {
  justify-content: flex-start(預設) | flex-end | center | space-between | space-around | space-evenly;
}

align-items

排列 flex items 的次要象限方法

.container {
  align-items: flex-start(預設) | flex-end | center | baseline | stretch;
}

align-content

排列 flex container 的line

.container {
  align-content: flex-start | flex-end | center | space-between | space-around | stretch;
}

flex items

Properties for the Children

item

order

指定 flex item 的順序

.item {
  order: <integer>; /* default is 0 */
}

flex-grow

flex container 底下 item 的比例預設是1

.item {
  flex-grow: <number>; /* default 0 */
}

flex-shrink

flex-item 收縮比例預設是1

.item {
  flex-shrink: <number>; /* default 1 */
}

flex-basis

定義一個 element size 在保留空間之前

.item {
  flex-basis: <length> | auto; /* default auto */
}

flex

縮寫 flex-grow , flex-shrink, flex-basis 預設是 0 1 auto

.item {
  flex: none | [ <'flex-grow'> <'flex-shrink'>? || <'flex-basis'> ]
}

align-self

覆蓋過 align-items 的排列方法只針對這個 flex item

.item {
  align-self: auto | flex-start | flex-end | center | baseline | stretch;
}
⚠️ **GitHub.com Fallback** ⚠️