樣式 justifyContent 屬性
示例
在彈性 <div> 元素的項之間建立一些空間
document.getElementById("main").style.justifyContent = "space-between";
自己動手試一試 »
描述
當彈性容器的項未使用主軸(水平方向)上的所有可用空間時,justifyContent 屬性會對這些項進行對齊。
提示: 使用 alignContent 屬性來對齊交叉軸(垂直方向)上的項。
瀏覽器支援
屬性 | |||||
---|---|---|---|---|---|
justifyContent | 是 | 12.0 | 是 | 9.0 | 是 |
語法
返回 justifyContent 屬性
object.style.justifyContent
設定 justifyContent 屬性
object.style.justifyContent = "flex-start|flex-end|center|space-between|space-around|initial|inherit"
屬性值
值 | 描述 |
---|---|
flex-start | 預設值。項位於容器的開頭 |
flex-end | 項位於容器的末尾位置 |
center | 項位於容器的中心 |
space-between | 項被定位在行之間具有空間 |
space-around | 項被定位在行之前、之間和之後具有空間 |
initial | 將此屬性設定為其預設值。閱讀關於 initial |
inherit | 從其父元素繼承此屬性。閱讀關於 inherit |
技術詳情
預設值 | flex-start |
---|---|
返回值 | 字串,表示元素的 justify-content 屬性 |
CSS 版本 | CSS3 |
相關頁面
CSS 參考:justify-content 屬性
HTML DOM 樣式參考:alignContent 屬性
HTML DOM STYLE 參考:alignItems 屬性
HTML DOM STYLE 參考:alignSelf 屬性