monks/align_items
The CSS align-items property sets the {{cssxref(“align-self”)}} value on all direct children as a group. In flexbox, it controls the alignment of items on the {{glossary(“cross axis”)}}. In grid layout, it controls the alignment of items on the block axis within their {{glossary(“grid areas”)}}.
The interactive example below uses grid layout to demonstrate some of the values of this property.
Values
pub const baseline: #(String, String)
- : All flex items are aligned such that their flex container baselines align. The item with the largest distance between its cross-start margin edge and its baseline is flushed with the cross-start edge of the line.
pub const center: #(String, String)
- : The flex items’ margin boxes are centered within the line on the cross-axis. If the cross-size of an item is larger than the flex container, it will overflow equally in both directions.
pub const end: #(String, String)
- : The items are packed flush to each other toward the end edge of the alignment container in the appropriate axis.
pub const flex_end: #(String, String)
- : Used in flex layout only, aligns the flex items flush against the flex container’s main-end or cross-end side. When used outside of a flex formatting context, this value behaves as
end.
pub const flex_start: #(String, String)
- : Used in flex layout only, aligns the flex items flush against the flex container’s main-start or cross-start side. When used outside of a flex formatting context, this value behaves as
start.
pub const normal: #(String, String)
- : The effect of this keyword is dependent of the layout mode we are in: - In absolutely-positioned layouts, the keyword behaves like
starton replaced absolutely-positioned boxes, and asstretchon all other absolutely-positioned boxes. - In static position of absolutely-positioned layouts, the keyword behaves asstretch. - For flex items, the keyword behaves asstretch. - For grid items, this keyword leads to a behavior similar to the one ofstretch, except for boxes with an {{glossary(“aspect ratio”)}} or an intrinsic size where it behaves likestart. - The property doesn’t apply to block-level boxes, and to table cells.
pub const revert_layer: #(String, String)
pub const safe: #(String, String)
- : Used alongside an alignment keyword. If the chosen keyword means that the item overflows the alignment container causing data loss, the item is instead aligned as if the alignment mode were
start.
pub const self_end: #(String, String)
- : The items are packed flush to the edge of the alignment container’s end side of the item, in the appropriate axis.
pub const self_start: #(String, String)
- : The items are packed flush to the edge of the alignment container’s start side of the item, in the appropriate axis.
pub const start: #(String, String)
- : The items are packed flush to each other toward the start edge of the alignment container in the appropriate axis.
pub const stretch: #(String, String)
- : If the item’s cross-size is
auto, the used size is set to the length necessary to be as close to filling the container as possible, respecting the item’s width and height limits. If the item is not auto-sized, this value falls back toflex-start, and toself-startorself-endif the container’s {{cssxref(“align-content”)}} isfirst baseline(orbaseline) orlast baseline.
pub const unsafe: #(String, String)
- : Used alongside an alignment keyword. Regardless of the relative sizes of the item and alignment container and whether overflow which causes data loss might happen, the given alignment value is honored.There are also two values that were defined for flexbox, as they are base on flex model axes concepts, that work in grid layouts as well: