樣式 alignSelf 屬性
示例
設定彈性元素內其中一個專案以適應容器的對齊方式。
document.getElementById("myBlueDiv").style.alignSelf = "stretch";
自己動手試一試 »
描述
alignSelf 屬性指定彈性容器內所選專案的對齊方式。
注意:alignSelf 屬性會覆蓋彈性容器的 alignItems 屬性。
語法
返回 alignSelf 屬性
object.style.alignSelf
設定 alignSelf 屬性
object.style.alignSelf = "auto|stretch|center|flex-start|flex-end|baseline|initial|inherit"
屬性值
值 | 描述 |
---|---|
auto | 預設。元素繼承其父容器的 align-items 屬性,如果它沒有父容器,則為 "stretch"。 |
stretch | 元素被定位以適應容器。 |
center | 元素被定位在容器的中心。 |
flex-start | 元素被定位在容器的開始位置。 |
flex-end | 元素被定位在容器的結束位置。 |
baseline(基線) | 元素被定位在容器的基線上。 |
initial | 將此屬性設定為其預設值。閱讀關於 initial |
inherit | 從其父元素繼承此屬性。閱讀關於 inherit |
技術詳情
預設值 | auto |
---|---|
返回值 | 一個字串,表示元素的 align-self 屬性。 |
CSS 版本 | CSS3 |
瀏覽器支援
alignSelf
是一個 CSS3 (1999) 特性。
所有瀏覽器都完全支援。
Chrome | Edge | Firefox | Safari | Opera | IE |
是 | 是 | 是 | 是 | 是 | 11 |
相關頁面
CSS 參考:align-self 屬性
HTML DOM 樣式參考:alignContent 屬性
HTML DOM STYLE 參考:alignItems 屬性