Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

CSS align-content Property

CSS align-content Property

CSS Reference Manual CSS Reference Manual

Example

Aligns the flexbox's

container:

div

{

display:

flex

;

flex-flow:

row

wrap

;

align-content:

space-around

;

}

Try it »


Browser support

The numbers in the table indicate the version number of the first browser that supports this property.

The number immediately following -webkit-, -ms-, or -moz- is the first version that supports the prefixed property.

property
align-content 21.0 11.0 28.0 9.0
7.0 -webkit- 12.1

Definition and Usage

The align-content property aligns items inside a flex container when they do not occupy all available space on the cross axis (vertical).

**Tip:** Use the justify-content property to align items on the main axis (horizontal).

**Note:** The container must have multiple lines of items for this property to have a visible effect.

Default value: stretch
Inherited: No
Animatable: No. See Animatable.
Version: CSS3
JavaScript syntax: object.style.alignContent="center" Try it

CSS Syntax

align-content: stretch|center|flex-start|flex-end|space-between|space-around|initial|inherit;

Default value

Value Description Testing
stretch

Default value. The element is stretched to fit the container.

Each line will stretch to take up the remaining space. If the remaining space is negative, this value is equivalent to 'flex-start'. Otherwise, the remaining space is divided equally among all lines to expand their cross-axis size.

Test »
center

The element is located at the center of the container.

Each line is stacked toward the middle of the flex container. Lines are packed together and centered in the flex container, keeping the distance between the container's cross-start content edge and the first line equal to the distance between the container's cross-end content edge and the last line. (If the remaining space is negative, lines overflow equally in both directions.)

Test »
flex-start

The element is located at the beginning of the container.

Each

line is stacked toward the start of the flex container. The cross-start edge of the first line in the flex container is flush with the cross-start edge of the flex container, and each subsequent line is flush with the previous one.

Test »
flex-end

The element is located at the end of the container.

Each line is stacked toward the end of the flex container. The cross-end edge of the last line in the flex container is flush with the cross-end edge of the flex container, and each subsequent line is flush with the previous one.

Test »
space-between

The element is positioned in a container with space left between the lines.

Each line is evenly distributed in the flex container. If the remaining space is negative or the flex container has only one line, this value is equivalent to 'flex-start'. Otherwise, the cross-start edge of the first line is flush with the container's cross-start content edge, the cross-end edge of the last line is flush with the container's cross-end content edge, and the remaining lines are arranged so that the space between each pair is equal.

Test »
space-around

The element is positioned in a container with space left before, between, and after the lines.

Each line is evenly distributed in the flex container, with half the size of the space between child elements kept at both ends. If the remaining space is negative or the flex container has only one line, this value is equivalent to 'center'. Otherwise, the lines are arranged in the flex container so that the space between each pair is equal, while the space before the first line and after the last line is half the other spaces.

Test »
initial Sets this property to its default value. See initial. Test »
inherit Inherits this property from its parent element. See inherit.

Related Articles

CSS Reference Manual:align-items Property

CSS Reference Manual:align-self Property

CSS Reference Manual:justify-content Property

CSS Reference Manual CSS Reference Manual