Flexbox - fantasy0107/notes GitHub Wiki
Properties for the Parent
定義為 flexbox
.container {
display: flex; /* or inline-flex */
}
flexbox 的方向
.container {
flex-direction: row(預設) | row-reverse | column | column-reverse;
}
預設是同一列或行但如果想要改變就用這個
.container{
flex-wrap: nowrap(預設) | wrap | wrap-reverse;
}
縮寫 flex-direction 和 flex-wrap
flex-flow: <‘flex-direction’> || <‘flex-wrap’>
預設是 row nowrap
排列 flex items 的主要象限方法
.container {
justify-content: flex-start(預設) | flex-end | center | space-between | space-around | space-evenly;
}
排列 flex items 的次要象限方法
.container {
align-items: flex-start(預設) | flex-end | center | baseline | stretch;
}
排列 flex container 的line
.container {
align-content: flex-start | flex-end | center | space-between | space-around | stretch;
}
Properties for the Children
指定 flex item 的順序
.item {
order: <integer>; /* default is 0 */
}
flex container 底下 item 的比例預設是1
.item {
flex-grow: <number>; /* default 0 */
}
flex-item 收縮比例預設是1
.item {
flex-shrink: <number>; /* default 1 */
}
定義一個 element size 在保留空間之前
.item {
flex-basis: <length> | auto; /* default auto */
}
縮寫 flex-grow , flex-shrink, flex-basis 預設是 0 1 auto
.item {
flex: none | [ <'flex-grow'> <'flex-shrink'>? || <'flex-basis'> ]
}
覆蓋過 align-items 的排列方法只針對這個 flex item
.item {
align-self: auto | flex-start | flex-end | center | baseline | stretch;
}