目录

style justifyContent 属性

示例

在灵活的 <div> 元素的项目之间留出一些空间:

document.getElementById("main").style.justifyContent = "space-between";
亲自试一试 »

描述

当项目未使用主轴(水平)上的所有可用空间时, justifyContent 属性会对齐灵活容器的项目。

提示:使用alignContent 属性在横轴上(垂直)对齐项目。


浏览器支持

Property
justifyContent Yes 12.0 Yes 9.0 Yes

语法

返回 justifyContent 属性:

object.style.justifyContent

设置 justifyContent 属性:

object.style.justifyContent = "flex-start|flex-end|center|space-between|space-around|initial|inherit"

属性值

Value Description
flex-start Default value. Items are positioned at the beginning of the container
flex-end Items are positioned at the end of the container
center Items are positioned at the center of the container
space-between Items are positioned with space between the lines
space-around Items are positioned with space before, between, and after the lines
initial Sets this property to its default value. Read about initial
inherit Inherits this property from its parent element. Read about inherit

技术细节

默认值: 弹性启动
返回值: 一个字符串,表示元素的 justify-content 属性
CSS版本 CSS3

相关页面

CSS 参考:调整内容属性

HTML DOM 样式参考:对齐内容属性

HTML DOM 样式参考:对齐项目属性

HTML DOM 样式参考:对齐自属性