在灵活的 <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 样式参考:对齐自属性
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!