{"id":21073,"date":"2013-04-11T11:00:42","date_gmt":"2013-04-11T18:00:42","guid":{"rendered":"http:\/\/css-tricks.com\/?page_id=21073"},"modified":"2022-09-28T13:43:59","modified_gmt":"2022-09-28T20:43:59","slug":"align-items","status":"publish","type":"page","link":"https:\/\/css-tricks.com\/almanac\/properties\/a\/align-items\/","title":{"rendered":"align-items"},"content":{"rendered":"\n
The The Imagine a horizontal flexbox layout. That horizontal flow is the main axis, so align-items is the alignment opposite that, on the vertical axis. Bear in mind that changes when the main axis changes, and the cross axis changes with it.<\/p>\n\n\n\n You can think of The rest of this article is fairly focused on flexbox rather than grid. The concepts are still very similar, but there are some differences. For example, in flexbox, the axises can change, where in grid they cannot. That effects things like flexbox having values like The The following figure helps understand how flex items are layed out depending on the The following demo shows how flex items are layed out depending on the align-items<\/code> property is related to CSS layout. It effects how elements are aligned both in Flexbox<\/a> and Grid<\/a> layouts.<\/p>\n\n\n\n
.container {\n display: flex;\n align-items: flex-start;\n}<\/code><\/pre>\n\n\n\n
align-items<\/code> in Flexbox<\/a><\/li>
align-items<\/code> in Grid<\/a><\/li><\/ul>\n\n\n
Syntax<\/h3>\n\n\n
align-items: flex-start | flex-end | center | baseline | stretch\n<\/code><\/pre>\n\n\n\n\n\n\n\n
align-items<\/code> property defines the default behavior for how items are laid out along the cross axis<\/strong> (perpendicular to the main axis).<\/p>\n\n\n\n
align-items<\/code> as the
justify-content<\/code> version for the cross-axis (perpendicular to the main-axis).<\/p>\n\n\n\n
flex-start<\/code> where in grid it is just
start<\/code>.<\/p>\n\n\n\n
align-items<\/code> property accepts 5 different values:<\/p>\n\n\n\n
flex-start<\/code>: cross-start margin edge of the items is placed on the cross-start line<\/li>
flex-end<\/code>: cross-end margin edge of the items is placed on the cross-end line<\/li>
center<\/code>: items are centered in the cross-axis<\/li>
baseline<\/code>: items are aligned such as their baselines align<\/li>
stretch<\/code> (default<\/strong>): stretch to fill the container (still respect min-width\/max-width)<\/li><\/ul>\n\n\n\n
align-items<\/code> value.<\/p>\n\n\n\n
Demo<\/h3>\n\n\n
align-items<\/code> value:<\/p>\n\n\n\n
flex-start<\/code><\/li>
flex-end<\/code><\/li>
center<\/code><\/li>
baseline<\/code><\/li>
stretch<\/code><\/li><\/ul>\n\n\n\n