## flex-direction flex-direction 属性设置弹性容器中的子元素的布局方向,该方向定义为主轴,另一个垂直与它的方向为交叉轴。 ### uni-app x 兼容性 Web: 4.0; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61 ### App平台拍平(flatten)兼容性 @flatten_compatibility | Android(Vapor) | iOS(Vapor) | HarmonyOS(Vapor) | | :- | :- | :- | | 5.21 | 5.11 | 5.0 | ### 语法 ``` flex-direction: row | row-reverse | column | column-reverse; ``` ### 值限制 - enum ### flex-direction 的属性值 | 名称 | 兼容性 | 描述 | | :- | :- | :- | | row | Web: 4.0; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61 | flex 容器的主轴被定义为与文本方向相同。主轴起点和主轴终点与内容方向相同。 | | row-reverse | Web: 4.0; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61 | 表现和 row 相同,但是置换了主轴起点和主轴终点 | | column | Web: 4.0; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61 | flex 容器的主轴和块轴相同。主轴起点与主轴终点和书写模式的前后点相同 | | column-reverse | Web: 4.0; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61 | 表现和column相同,但是置换了主轴起点和主轴终点 | ### 默认值 @default-value | 平台 | 默认值 | | :- | :- | | uvue | column | **注意**:W3C 默认值为:row ### 适用组件 @unix-tags - [view](/component/view.md) - [scroll-view](/component/scroll-view.md) - [list-item](/component/list-item.md) - [swiper-item](/component/swiper-item.md) - [flow-item](/component/flow-item.md) - [navigator](/component/navigator.md) ### 示例 示例为[hello uni-app x alpha分支](https://gitcode.com/dcloud/hello-uni-app-x/blob/prod_alpha/pages/CSS/flex/flex-direction.uvue),与最新HBuilderX Alpha版同步。与最新正式版同步的master分支示例[另见](https://gitcode.com/dcloud/hello-uni-app-x/blob/master//pages/CSS/flex/flex-direction.uvue) ::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/CSS/flex/flex-direction > appRedirect https://hellouniappx.dcloud.net.cn/appredirect.html?path=pages/CSS/flex/flex-direction >示例 ```vue ``` ::: ### 参见 - [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/flex-direction) - [相关 Bug](https://issues.dcloud.net.cn/?mid=css.properties.flex.flex-direction)