- 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 |