flex flex-grow flex-shrink flex-basis flex-flow flex-direction flex-wrap align-content align-items align-self justify-content orderflex
(1) flex: none | <' flex-grow '> <' flex-shrink >' || <' flex-basis '>spa
(a) <' flex-grow '> : 當剩餘空間 > 0 子項分配空間的比例3d
(b) <' flex-shrink >':當剩餘空間 < 0 在收縮的時候收縮比率會以伸縮基準值加權code
(c) <' flex-basis '>:「flex子項」長度的起始數值blog
例子:element
<style> .flex{ display:flex; width:800px; margin:0; padding:0; list-style:none; } .flex :nth-child(1){ flex:1 1 300px; } .flex :nth-child(2){ flex:1 2 200px; } .flex :nth-child(3){ flex:3 3 400px; } </style> <ul class="flex"> <li>a</li> <li>b</li> <li>c</li> </ul>
剩餘空間: 800-300-200-400 = -100<0it
加權:300*1+200*2+400*3 = 1900;io
a被移除的空間: (300*1/1900)*100 約等於 16class
a的實際空間 : 300-16容器
b被移除的空間: (200*2/1900)*100
c被移除的空間: (400*3/1900)*100
用的是<' flex-shrink >'這列的比例
-----------------------------------------------------------------------------------------
若是上面例子中的flex的width爲1500, 則會使用<' flex-grow '>,則計算以下:
1500-300-200-400 = 600>0
a的擴展量: 1/(1+1+3)*600=120
a的實際寬度:300+120
(2) flex-flow:<' flex-direction '> || <' flex-wrap '>
(a)flex-direction:row | row-reverse | column | column-reverse
(b)flex-wrap:nowrap | wrap | wrap-reverse
nowrap:flex容器爲單行。該狀況下flex子項可能會溢出容器
wrap:flex容器爲多行。該狀況下flex子項溢出的部分會被放置到新行,子項內部會發生斷行
wrap-reverse:反轉 wrap 排列。
------align-content 和 justify-content 是針對整個flex container裏的 content-----------------------------------------------------------------------------------------------------------------------------------------------------
(3)align-content:flex-start | flex-end | center | space-between | space-around | stretch
注意a: 當box-orient: 與 box-align類似,可是 box-align 屬性不會自動換行,超出父級的部分仍會一行顯示
b: 當伸縮容器的側軸還有多餘空間時,多行才起做用
(4) justify-content(當flex-direction爲 column 或 column-reverse 不起做用):flex-start | flex-end | center | space-between | space-around
注意a: 與align-content相比,超出一行並不會換行,但仍起效果。
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
(5)align-items(做用於父節點):flex-start | flex-end | center | baseline | stretch 縱值
(6)align-self(做用於子節點):auto | flex-start | flex-end | center | baseline | stretch 做用於該樣式的標籤上
(7)order:<integer>
用整數值來定義排列順序,數值小的排在前面。能夠爲負值。相似於box-ordinal-group