HTML: <div class="container"> <img src="img/banner1.jpg" alt=""> <figcaption>設置或檢索彈性盒伸縮基準值。若是全部子元素的基準值之和大於剩餘空間,則會根據每項設置的基準值,按比率伸縮剩餘空間對應的腳本特性爲flexBasis。flex-wrap 屬性規定flex容器是單⾏或者多⾏,同時橫軸的⽅向決定了新⾏堆疊的⽅向。。</figcaption> </div> CSS: .container{ display: flex; }
結果爲:css
flex-direction:row;//從左到右
flex-direction:row-reverse;//從右到左
flex-direction:column;//從上到下
flex-dirction:column-reverse;//從下到上
flex-wrap:wrap;//折行
flex-wrap:wrap-reverse;//改變行的序列
flex-flow:row nowrap;
頁面爲:佈局
HTML: <div class="container"> <div class="content first"> <figcaption>1.文章,1984年6月26日出生於陝西省西安市,中國內地男演員、導演。</figcaption> </div> <div class="content second"> <figcaption>2.文章,1984年6月26日出生於陝西省西安市,中國內地男演員、導演。</figcaption> </div> <div class="content three"> <figcaption>3.文章,1984年6月26日出生於陝西省西安市,中國內地男演員、導演。</figcaption> </div> </div> CSS: .container{ display: flex; flex-direction: column; } .content{ border: 1px dashed mediumaquamarine; } .first{ order: 2; } .second{ order:3 } .three{ order:1 }
CSS:
.content{
width: 200px;
}
.second{
flex-grow: 1;
}
CSS:
.content{
width: 1000px;
}
.second{
flex-shrink: 2;
}
.content{
flex-basis: 420px;
}
//flex-grow,flex-shrink,flex-basis
flex:1 1 420px