
- CSS 教程
- CSS - 首頁
- CSS - 路線圖
- CSS - 簡介
- CSS - 語法
- CSS - 選擇器
- CSS - 包含
- CSS - 測量單位
- CSS - 顏色
- CSS - 背景
- CSS - 字型
- CSS - 文字
- CSS - 圖片
- CSS - 連結
- CSS - 表格
- CSS - 邊框
- CSS - 塊級邊框
- CSS - 內聯邊框
- CSS - 外邊距
- CSS - 列表
- CSS - 內邊距
- CSS - 游標
- CSS - 輪廓
- CSS - 尺寸
- CSS - 捲軸
- CSS - 內聯塊
- CSS - 下拉選單
- CSS - 可見性
- CSS - 溢位
- CSS - 清除浮動
- CSS - 浮動
- CSS - 箭頭
- CSS - 調整大小
- CSS - 引號
- CSS - 順序
- CSS - 位置
- CSS - 連字元
- CSS - 懸停
- CSS - 顯示
- CSS - 聚焦
- CSS - 縮放
- CSS - 轉換
- CSS - 高度
- CSS - 連字元字元
- CSS - 寬度
- CSS - 不透明度
- CSS - Z 索引
- CSS - 底部
- CSS - 導航欄
- CSS - 覆蓋層
- CSS - 表單
- CSS - 對齊
- CSS - 圖示
- CSS - 影像庫
- CSS - 註釋
- CSS - 載入器
- CSS - 屬性選擇器
- CSS - 組合器
- CSS - 根元素
- CSS - 盒模型
- CSS - 計數器
- CSS - 剪裁
- CSS - 書寫模式
- CSS - Unicode-bidi
- CSS - min-content
- CSS - All
- CSS - Inset
- CSS - Isolation
- CSS - Overscroll
- CSS - Justify Items
- CSS - Justify Self
- CSS - Tab Size
- CSS - Pointer Events
- CSS - Place Content
- CSS - Place Items
- CSS - Place Self
- CSS - Max Block Size
- CSS - Min Block Size
- CSS - Mix Blend Mode
- CSS - Max Inline Size
- CSS - Min Inline Size
- CSS - Offset
- CSS - Accent Color
- CSS - User Select
- CSS 高階
- CSS - 網格
- CSS - 網格佈局
- CSS - Flexbox
- CSS - 可見性
- CSS - 定位
- CSS - 圖層
- CSS - 偽類
- CSS - 偽元素
- CSS - @規則
- CSS - 文字效果
- CSS - 分頁媒體
- CSS - 列印
- CSS - 佈局
- CSS - 驗證
- CSS - 圖片精靈
- CSS - Important
- CSS - 資料型別
- CSS3 教程
- CSS3 - 教程
- CSS - 圓角
- CSS - 邊框影像
- CSS - 多背景
- CSS - 顏色
- CSS - 漸變
- CSS - 盒陰影
- CSS - 盒裝飾中斷
- CSS - Caret Color
- CSS - 文字陰影
- CSS - 文字
- CSS - 2d 變換
- CSS - 3d 變換
- CSS - 過渡
- CSS - 動畫
- CSS - 多列
- CSS - 盒尺寸
- CSS - 工具提示
- CSS - 按鈕
- CSS - 分頁
- CSS - 變數
- CSS - 媒體查詢
- CSS - 函式
- CSS - 數學函式
- CSS - 遮罩
- CSS - 形狀
- CSS - 樣式影像
- CSS - 特異性
- CSS - 自定義屬性
- CSS 響應式
- CSS RWD - 簡介
- CSS RWD - 視口
- CSS RWD - 網格檢視
- CSS RWD - 媒體查詢
- CSS RWD - 圖片
- CSS RWD - 影片
- CSS RWD - 框架
- CSS 工具
- CSS - PX 到 EM 轉換器
- CSS - 顏色選擇器和動畫
- CSS 資源
- CSS - 有用資源
- CSS - 討論
CSS - flex-flow 屬性
CSS flex-flow 是一個簡寫屬性,用於定義 flex-direction 和 flex-wrap 屬性的值,這兩個屬性分別用於在一個語句中確定彈性容器的方向及其內容的換行行為。元素必須是靈活的,以便該屬性顯示其效果。
語法
flex-flow: flex-direction flex-wrap | initial | inherit;
屬性值
值 | 描述 |
---|---|
flex-direction | 它指定彈性專案的排列方向。可能的值為:row、row-reverse、column、column-reverse、initial 和 inherit。預設值為 row。 |
flex-wrap | 它指定彈性專案是否應該換行。可能的值為:nowrap、wrap、wrap-reverse、initial 和 inherit。 |
initial | 這將屬性設定為其預設值。 |
inherit | 這從父元素繼承該屬性。 |
CSS Flex Flow 屬性示例
以下示例說明了使用不同值的 flex-flow 屬性。
使用 Row 方向的 Flex Flow 屬性
要在一個語句中設定元素的方向和換行,我們使用 flex-flow 屬性。它接受一個或兩個值。在以下示例中,使用了兩個值 flex-direction: row 和 flex-wrap: nowrap, wrap 和 wrap-reverse。
示例
<!DOCTYPE html> <html> <head> <style> .container { background-color: lightgray; padding: 10px; margin-bottom: 20px; } .item { background-color: #4CAF50; color: white; border: 1px solid black; padding: 10px; margin: 5px; flex: 0 0 100px; } .container1 { display: flex; flex-flow: row nowrap; width: 400px; } .container2 { display: flex; flex-flow: row wrap; width: 300px; } .container3 { display: flex; flex-flow: row wrap-reverse; width: 300px; } </style> </head> <body> <h2> CSS flex-flow Property </h2> <p> <strong> Flex Flow: row nowrap </strong> -Items are arranged in a row and do not wrap, causing horizontal overflow if the items exceed the container's width. </p> <div class="container container1"> <div class="item"> Item 1 </div> <div class="item"> Item 2 </div> <div class="item"> Item 3 </div> <div class="item"> Item 4 </div> <div class="item"> Item 5 </div> </div> <p> <strong> Flex Flow: row wrap </strong> - Items are arranged in a row and wrap onto the next line if there isn't enough space in the container. </p> <div class="container container2"> <div class="item"> Item 1 </div> <div class="item"> Item 2 </div> <div class="item"> Item 3 </div> <div class="item"> Item 4 </div> <div class="item"> Item 5 </div> </div> <p> <strong> Flex Flow: row wrap-reverse </strong> - Items are arranged in a row and wrap onto the next line in reverse order if there isn't enough space in the container. </p> <div class="container container3"> <div class="item"> Item 1 </div> <div class="item"> Item 2 </div> <div class="item"> Item 3 </div> <div class="item"> Item 4 </div> <div class="item"> Item 5 </div> </div> </body> </html>
使用 Row Reverse 方向的 Flex Flow 屬性
要在一個語句中設定元素的方向和換行,我們使用 flex-flow 屬性。它接受一個或兩個值。在以下示例中,使用了兩個值 flex-direction: row-reverse 和 flex-wrap: nowrap, wrap 和 wrap-reverse。
示例
<!DOCTYPE html> <html> <head> <style> .container { background-color: lightgray; padding: 10px; margin-bottom: 20px; } .item { background-color: #4CAF50; color: white; border: 1px solid black; padding: 10px; margin: 5px; flex: 0 0 100px; } .container1 { display: flex; flex-flow: row-reverse nowrap; width: 400px; margin-left: auto; } .container2 { display: flex; flex-flow: row-reverse wrap; width: 300px; } .container3 { display: flex; flex-flow: row-reverse wrap-reverse; width: 300px; } </style> </head> <body> <h2> CSS flex-flow property </h2> <p> <strong> Flex Flow: row-reverse nowrap </strong> - Items are arranged in a row in reverse order and do not wrap, causing horizontal overflow if the items exceed the container's width. </p> <div class="container container1"> <div class="item"> Item 1 </div> <div class="item"> Item 2 </div> <div class="item"> Item 3 </div> <div class="item"> Item 4 </div> <div class="item"> Item 5 </div> </div> <p> <strong> Flex Flow: row-reverse wrap </strong> - Items are arranged in a row in reverse order and wrap onto the next line if there isn't enough space in the container. </p> <div class="container container2"> <div class="item"> Item 1 </div> <div class="item"> Item 2 </div> <div class="item"> Item 3 </div> <div class="item"> Item 4 </div> <div class="item"> Item 5 </div> </div> <p> <strong> Flex Flow: row-reverse wrap-reverse </strong> - Items are arranged in a row in reverse order and wrap onto the next line in reverse order if there isn't enough space in the container. </p> <div class="container container3"> <div class="item"> Item 1 </div> <div class="item"> Item 2 </div> <div class="item"> Item 3 </div> <div class="item"> Item 4 </div> <div class="item"> Item 5 </div> </div> </body> </html>
使用 Column 方向的 Flex Flow 屬性
要在一個語句中設定元素的方向和換行,我們使用 flex-flow 屬性。它接受一個或兩個值。在以下示例中,使用了兩個值 flex-direction: column 和 flex-wrap: nowrap, wrap 和 wrap-reverse。
示例
<!DOCTYPE html> <html> <head> <style> .container { background-color: lightgray; padding: 10px; margin-bottom: 20px; width: 300px; height: 400px; overflow: auto; } .item { background-color: #4CAF50; color: white; border: 1px solid black; padding: 10px; margin: 5px; flex: 0 0 100px; } .container1 { display: flex; flex-flow: column nowrap; } .container2 { display: flex; flex-flow: column wrap; } .container3 { display: flex; flex-flow: column wrap-reverse; } </style> </head> <body> <h2> CSS flex-flow property </h2> <p> <strong> Flex Flow: column nowrap </strong> - Items are arranged in a vertical column and do not wrap. Vertical scrolling will occur if the items exceed the container's height. </p> <div class="container container1"> <div class="item"> Item 1 </div> <div class="item"> Item 2 </div> <div class="item"> Item 3 </div> <div class="item"> Item 4 </div> <div class="item"> Item 5 </div> </div> <p> <strong> Flex Flow: column wrap </strong> - Items are arranged in a vertical column and wrap onto the next line when there isn't enough space in the container. </p> <div class="container container2"> <div class="item"> Item 1 </div> <div class="item"> Item 2 </div> <div class="item"> Item 3 </div> <div class="item"> Item 4 </div> <div class="item"> Item 5 </div> <div class="item"> Item 6 </div> <div class="item"> Item 7 </div> </div> <p> <strong> Flex Flow: column wrap-reverse </strong> - Items are arranged in a vertical column and wrap onto the next line in reverse order when there isn't enough space in the container. </p> <div class="container container3"> <div class="item"> Item 1 </div> <div class="item"> Item 2 </div> <div class="item"> Item 3 </div> <div class="item"> Item 4 </div> <div class="item"> Item 5 </div> <div class="item"> Item 6 </div> <div class="item"> Item 7 </div> </div> </body> </html>
使用 Column Reverse 方向的 Flex Flow 屬性
要在一個語句中設定元素的方向和換行,我們使用 flex-flow 屬性。它接受一個或兩個值。在以下示例中,使用了兩個值 flex-direction: column-reverse 和 flex-wrap: nowrap, wrap 和 wrap-reverse。
示例
<!DOCTYPE html> <html> <head> <style> .container { background-color: lightgray; padding: 10px; margin-bottom: 20px; width: 300px; height: 400px; overflow: auto; } .item { background-color: #4CAF50; color: white; border: 1px solid black; padding: 10px; margin: 5px; flex: 0 0 100px; } .container1 { display: flex; flex-flow: column-reverse nowrap; } .container2 { display: flex; flex-flow: column-reverse wrap; } .container3 { display: flex; flex-flow: column-reverse wrap-reverse; } </style> </head> <body> <h2> CSS Flex Flow Property with column-reverse </h2> <p> <strong> Flex Flow: column-reverse nowrap </strong> - Items are arranged in a vertical column in reverse order and do not wrap. Vertical scrolling will occur if the items exceed the container's height. </p> <div class="container container1"> <div class="item"> Item 1 </div> <div class="item"> Item 2 </div> <div class="item"> Item 3 </div> <div class="item"> Item 4 </div> <div class="item"> Item 5 </div> </div> <p> <strong> Flex Flow: column-reverse wrap </strong> - Items are arranged in a vertical column in reverse order and wrap onto the next column when there isn't enough vertical space in the container. </p> <div class="container container2"> <div class="item"> Item 1 </div> <div class="item"> Item 2 </div> <div class="item"> Item 3 </div> <div class="item"> Item 4 </div> <div class="item"> Item 5 </div> <div class="item"> Item 6 </div> <div class="item"> Item 7 </div> </div> <p> <strong> Flex Flow: column-reverse wrap-reverse </strong> - Items are arranged in a vertical column in reverse order and wrap onto the next column in reverse order when there isn't enough vertical space in the container. </p> <div class="container container3"> <div class="item"> Item 1 </div> <div class="item"> Item 2 </div> <div class="item"> Item 3 </div> <div class="item"> Item 4 </div> <div class="item"> Item 5 </div> <div class="item"> Item 6 </div> <div class="item"> Item 7 </div> </div> </body> </html>
僅使用 Flex Direction 值的 Flex Flow 屬性
要在一個語句中設定元素的方向和換行,我們使用 flex-flow 屬性。它最多接受兩個值。如果只給出一個值,則另一個值將是該屬性的預設值。在以下示例中,使用了單個值 flex-direction: row 和 flex-direction: row-reverse,flex-wrap 在這兩種情況下都採用預設值“nowrap”。
示例
<!DOCTYPE html> <html> <head> <style> .container { border: 2px solid #000; padding: 10px; margin-bottom: 20px; width: 50%; } .item { background-color: #4CAF50; color: white; border: 1px solid black; padding: 10px; margin: 5px; flex: 0 0 100px; } .container1 { display: flex; flex-flow: row; } .container2 { margin-left: auto; display: flex; flex-flow: row-reverse; } </style> </head> <body> <h2> CSS flex-flow property </h2> <p> <strong> Flex Flow: row (nowrap) </strong> - Items are arranged in a horizontal row from left to right and do not wrap. Horizontal scrolling will occur if the items exceed the container's width. </p> <div class="container container1"> <div class="item"> Item 1 </div> <div class="item"> Item 2 </div> <div class="item"> Item 3 </div> <div class="item"> Item 4 </div> <div class="item"> Item 5 </div> </div> <p> <strong> Flex Flow: row-reverse (nowrap) </strong> - Items are arranged in a horizontal row in reverse order from right to left and do not wrap. Horizontal scrolling will occur if the items exceed the container's width. </p> <div class="container container2"> <div class="item"> Item 1 </div> <div class="item"> Item 2 </div> <div class="item"> Item 3 </div> <div class="item"> Item 4 </div> <div class="item"> Item 5 </div> </div> </body> </html>
僅使用 Flex Direction 值的 Flex Flow 屬性
要在一個語句中設定元素的方向和換行,我們使用 flex-flow 屬性。它最多接受兩個值。如果只給出一個值,則另一個值將是該屬性的預設值。在以下示例中,使用了單個值 flex-direction: column 和 flex-direction: column-reverse,flex-wrap 在這兩種情況下都採用預設值“nowrap”。
示例
<!DOCTYPE html> <html> <head> <style> .container { background-color: lightgray; padding: 10px; margin-bottom: 20px; width: 50%; } .item { background-color: #4CAF50; color: white; border: 1px solid black; padding: 10px; margin: 5px; flex: 0 0 100px; } .container1 { display: flex; flex-flow: column; } .container2 { display: flex; flex-flow: column-reverse; } </style> </head> <body> <h2> CSS flex-flow property </h2> <p> <strong> Flex Flow: row (nowrap) </strong> - Items are arranged in a vertical column from top to bottom and do not wrap. </p> <div class="container container1"> <div class="item"> Item 1 </div> <div class="item"> Item 2 </div> <div class="item"> Item 3 </div> <div class="item"> Item 4 </div> <div class="item"> Item 5 </div> </div> <p> <strong> Flex Flow: row-reverse (nowrap) </strong> - Items are arranged in a vertical column in reverse order from bottom to top and do not wrap. </p> <div class="container container2"> <div class="item"> Item 1 </div> <div class="item"> Item 2 </div> <div class="item"> Item 3 </div> <div class="item"> Item 4 </div> <div class="item"> Item 5 </div> </div> </body> </html>
僅使用 Flex Wrap 值的 Flex Flow 屬性
要在一個語句中設定元素的方向和換行,我們使用 flex-flow 屬性。它最多接受兩個值。如果只給出一個值,則另一個值將是該屬性的預設值。在以下示例中,使用了單個值 flex-wrap: nowrap、flex-wrap: wrap 和 flex-wrap: wrap-reverse,flex-direction 在所有情況下都採用預設值“row”。
示例
<!DOCTYPE html> <html> <head> <style> .container { border: 2px solid #000; padding: 10px; margin-bottom: 20px; width: 50%; } .item { background-color: #4CAF50; color: white; border: 1px solid black; padding: 10px; margin: 5px; flex: 0 0 100px; } .container1 { display: flex; flex-flow: nowrap; } .container2 { display: flex; flex-flow: wrap; } .container3 { display: flex; flex-flow: wrap-reverse; } </style> </head> <body> <h2> CSS flex-flow property </h2> <p> <strong> Flex Flow: nowrap </strong> - Items are arranged in a horizontal row from left to right and do not wrap. </p> <div class="container container1"> <div class="item"> Item 1 </div> <div class="item"> Item 2 </div> <div class="item"> Item 3 </div> <div class="item"> Item 4 </div> <div class="item"> Item 5 </div> </div> <p> <strong> Flex Flow: wrap </strong> - Items are arranged in a horizontal row in reverse order from right to left and do not wrap. </p> <div class="container container2"> <div class="item"> Item 1 </div> <div class="item"> Item 2 </div> <div class="item"> Item 3 </div> <div class="item"> Item 4 </div> <div class="item"> Item 5 </div> </div> <p> <strong> Flex Flow: wrap-reverse </strong> - Items are arranged in a horizontal row in reverse order from right to left and do not wrap. </p> <div class="container container2"> <div class="item"> Item 1 </div> <div class="item"> Item 2 </div> <div class="item"> Item 3 </div> <div class="item"> Item 4 </div> <div class="item"> Item 5 </div> </div> </body> </html>
支援的瀏覽器
屬性 | ![]() |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|---|
flex-flow | 29.0 | 11.0 | 28.0 | 9.0 | 17.0 |