CSS align-content property is used to align the content inside a flex container when there is extra space in the cross-axis. It is used to distribute the extra space between the rows or columns of a multi-line flex container. The align-content property is used in conjunction with the flex-wrap property, which specifies whether the flex items should wrap or not.
The align-content property has several possible values:
Let's take a look at some code examples:
In this example, the content is aligned to the start of the container:
.container {
display: flex;
flex-wrap: wrap;
align-content: flex-start;
}
In this example, the content is aligned to the end of the container:
.container {
display: flex;
flex-wrap: wrap;
align-content: flex-end;
}
In this example, the content is aligned to the center of the container:
.container {
display: flex;
flex-wrap: wrap;
align-content: center;
}
In this example, the content is distributed evenly between the rows or columns:
.container {
display: flex;
flex-wrap: wrap;
align-content: space-between;
}
In this example, the content is distributed evenly with equal space around each row or column:
.container {
display: flex;
flex-wrap: wrap;
align-content: space-around;
}
In this example, the content is stretched to fill the container:
.container {
display: flex;
flex-wrap: wrap;
align-content: stretch;
}
These are just a few examples of how the align-content property can be used. It is a powerful tool for aligning content inside a flex container and can be used in a variety of ways to achieve different layouts.
The align-content property is a useful tool for aligning content inside a flex container. It can be used in conjunction with the flex-wrap property to create multi-line flex containers and distribute the extra space between the rows or columns. By using the different values of the align-content property, you can achieve a variety of layouts and designs.