Flex是 Flexible Box 的縮寫(xiě)驯镊,彈性布局
容器的屬性
flex-direction:橫軸方向(row葫督,row-reverse竭鞍,column,column-reverse)
flex-wrap:換行(nowrap橄镜,wrap偎快,wrap-reverse)
flex-flow:flex-direction屬性和flex-wrap屬性簡(jiǎn)寫(xiě),默認(rèn)值row nowrap
justify-content:縱軸對(duì)齊方式(flex-start洽胶,flex-end晒夹,center,space-between姊氓,space-around)
align-items:縱軸對(duì)齊方式(flex-start丐怯,flex-end,center翔横,baseline响逢,stretch)
align-content:多軸對(duì)齊方式,只有一個(gè)軸不生效(flex-start棕孙,flex-end舔亭,center,space-between蟀俊,space-around钦铺,stretch)
justify-content、align-items分別為橫軸肢预,縱軸的對(duì)齊方式矛洞,但如果修改了flex-direction為column,它們對(duì)齊方式會(huì)交換烫映,也就是justify-content處理縱軸沼本,align-items處理橫軸。
容器內(nèi)元素屬性
order:定義元素的順序锭沟,默認(rèn)為0
flex-grow:元素放大抽兆,默認(rèn)為0,不放大
flex-shrink:元素縮小族淮,默認(rèn)為1辫红,空間不足將縮小,如果為0祝辣,將不縮小贴妻,固定大小
flex-basis:設(shè)置元素寬度,默認(rèn)auto蝙斜,元素內(nèi)容大忻汀(number|auto|initial|inherit)權(quán)重高于width,會(huì)覆蓋width
flex:flex-grow, flex-shrink 和 flex-basis的簡(jiǎn)寫(xiě)孕荠,默認(rèn)值為0 1 auto娩鹉。后兩個(gè)屬性可選
align-self:單獨(dú)設(shè)置每個(gè)元素的對(duì)齊方式攻谁,將覆蓋align-items屬性,默認(rèn)值為auto底循,繼承父元素的align-items屬性巢株,如果沒(méi)有父元素,則為stretch(auto熙涤,flex-start阁苞,flex-end,center祠挫,baseline那槽,stretch)