flex-flow

Baseline 已廣泛支援

此特性已相當成熟,可在許多裝置和瀏覽器版本上使用。自 2015 年 9 月以來,該特性已在各大瀏覽器中可用。

flex-flow CSS 簡寫屬性 指定了彈性容器的方向及其換行行為。

試一試

flex-flow: row wrap;
flex-flow: row-reverse nowrap;
flex-flow: column wrap-reverse;
flex-flow: column wrap;
<section class="default-example" id="default-example">
  <div class="transition-all" id="example-element">
    <div>Item One</div>
    <div>Item Two</div>
    <div>Item Three</div>
    <div>Item Four</div>
    <div>Item Five</div>
    <div>Item Six</div>
  </div>
</section>
#example-element {
  border: 1px solid #c5c5c5;
  width: 80%;
  max-height: 300px;
  display: flex;
}

#example-element > div {
  background-color: rgb(0 0 255 / 0.2);
  border: 3px solid blue;
  width: 60px;
  margin: 10px;
}

構成屬性

此屬性是以下 CSS 屬性的簡寫:

語法

css
/* flex-flow: <'flex-direction'> */
flex-flow: row;
flex-flow: row-reverse;
flex-flow: column;
flex-flow: column-reverse;

/* flex-flow: <'flex-wrap'> */
flex-flow: nowrap;
flex-flow: wrap;
flex-flow: wrap-reverse;

/* flex-flow: <'flex-direction'> and <'flex-wrap'> */
flex-flow: row nowrap;
flex-flow: column wrap;
flex-flow: column-reverse wrap-reverse;

/* Global values */
flex-flow: inherit;
flex-flow: initial;
flex-flow: revert;
flex-flow: revert-layer;
flex-flow: unset;

有關值的詳細資訊,請參閱 flex-directionflex-wrap

正式定義

初始值作為簡寫中的每個屬性
應用於彈性容器
繼承性
計算值作為簡寫中的每個屬性
動畫型別作為簡寫中的每個屬性

正式語法

flex-flow = 
<'flex-direction'> ||
<'flex-wrap'>

<flex-direction> =
row |
row-reverse |
column |
column-reverse

<flex-wrap> =
nowrap |
wrap |
wrap-reverse

示例

設定 column-reverse 和 wrap

在此示例中,主軸是塊方向,主起始點和主結束點已反轉。彈性專案允許換行,如果需要,會建立新行。

css
.container {
  flex-flow: column-reverse wrap;
}

規範

規範
CSS 彈性盒子佈局模組第 1 級
# flex-flow-屬性

瀏覽器相容性

另見