📅  最后修改于: 2023-12-03 14:39:04.788000             🧑  作者: Mango
The align-items
CSS property is used to set the vertical alignment of the items inside a flexbox container. It defines how the flex items are aligned when they are not stretched to fill the flex container.
flex-start | flex-end | center | stretch | baseline | first baseline | last baseline | safe center | unsafe center
.container {
display: flex;
align-items: center; /* Center align the items */
height: 300px;
}
.item {
background-color: #ddd;
margin: 10px;
height: 50px;
width: 50px;
}
The code above centers the flex items inside the container, both horizontally and vertically, with a height
of 300px
.
The align-items
property is a powerful tool for controlling the vertical alignment of the items inside a flex container. Use it to create more flexible and responsive layouts in your web design projects.