## justify-content
justify-content 属性设置弹性容器的子元素在主轴方向的对齐方式,控制如何在主轴方向分配内容元素之间和周围的空间。
### 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 |
### 语法
```
justify-content: normal | | ? [ | left | right ];
```
### 值限制
- enum
### justify-content 的属性值
| 名称 | 兼容性 | 描述 |
| :- | :- | :- |
| center | Web: 4.0; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61 | 元素紧密地排列在主轴方向居中对齐。第一个元素到主轴首的距离将与最后一个元素到主轴尾的距离相同 |
| flex-start | Web: 4.0; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61 | 元素紧密地排列在容器主轴起始侧 |
| flex-end | Web: 4.0; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61 | 元素紧密地排列在容器主轴结束侧 |
| space-between | Web: 4.0; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61 | 在主轴上均匀分配元素,相邻元素间距离相同。第一个元素与主轴首对齐,最后一个元素与主轴尾对齐 |
| space-around | Web: 4.0; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61 | 元素沿着主轴均匀分布在容器中,相邻元素间距离相同。主轴起始位置到第一个元素的间距,主轴结束位置到最后一个元素的间距,是相邻元素之间距离的一半 |
| space-evenly | Web: 4.0; Android: 4.61; iOS: 4.61; HarmonyOS: 4.61 | 元素都沿着主轴均匀分布在指定的对齐容器中。相邻元素之间的间距,主轴起始位置到第一个元素的间距,主轴结束位置到最后一个元素的间距,都完全一样 |
### 默认值 @default-value
| 平台 | 默认值 |
| :- | :- |
| uvue | flex-start |
**注意**:W3C 默认值为:normal
### 适用组件 @unix-tags
- [view](/component/view.md)
- [scroll-view](/component/scroll-view.md)
- [list-view](/component/list-view.md)
- [list-item](/component/list-item.md)
- [flow-item](/component/flow-item.md)
- [swiper-item](/component/swiper-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/justify-content.uvue),与最新HBuilderX Alpha版同步。与最新正式版同步的master分支示例[另见](https://gitcode.com/dcloud/hello-uni-app-x/blob/master//pages/CSS/flex/justify-content.uvue)
::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/CSS/flex/justify-content
> appRedirect https://hellouniappx.dcloud.net.cn/appredirect.html?path=pages/CSS/flex/justify-content
>示例
```vue
说明:左边是正常版本,右边是拍平版本
justify-content: center
justify-content: flex-start
justify-content: flex-end
justify-content: space-between
justify-content: space-around
justify-content: space-evenly
scroll-view 组件
justify-content:center 和 space-between
setProperty 设置与 getPropertyValue 获取
justify-content
设置值: {{data.justifyContent}}
获取值: {{data.justifyContentActual}}
拍平
设置值: {{data.justifyContent}}
获取值: {{data.justifyContentActualFlat}}
第一个枚举值,'' (空字符串) - 空值情况
```
:::
### 参见
- [MDN Reference](https://developer.mozilla.org/docs/Web/CSS/justify-content)
- [相关 Bug](https://issues.dcloud.net.cn/?mid=css.properties.flex.justify-content)