Language
日本語
English

Caution

JavaScript is disabled in your browser.
This site uses JavaScript for features such as search.
For the best experience, please enable JavaScript before browsing this site.

CSS Dictionary

  1. Home
  2. CSS Dictionary
  3. align-content

align-content

Specifies the spacing and alignment between rows when flex items wrap into multiple lines within a flex container. This property only takes effect when wrapping occurs with 'flex-wrap: wrap'.

Sample Code

/* Stretch rows to fill the container (default) */
.container { display: flex; flex-wrap: wrap; align-content: stretch;}

/* Align rows to the top */
.container-start { display: flex; flex-wrap: wrap; align-content: flex-start;}

/* Center the rows */
.container-center { display: flex; flex-wrap: wrap; align-content: center;}

/* Distribute rows evenly */
.container-between { display: flex; flex-wrap: wrap; align-content: space-between;}

Available Values

ValueDescription
stretch各行をコンテナの交差軸方向いっぱいに伸ばして配置します。初期Valueです。
flex-startAligns rows to the start of the cross axis.
flex-endAligns rows to the end of the cross axis.
centerCenters rows along the cross axis.
space-betweenPlaces the first row at the start, the last row at the end, and distributes the remaining rows evenly.
space-aroundDistributes rows with equal spacing on both sides of each row.
space-evenlyDistributes rows with completely equal spacing between all rows and edges.

Specification

PropertyDetails
初期Valuestretch
Applies toMulti-line flex containers (elements with 'flex-wrap: wrap')
InheritedNo
AnimationNot animatable (discrete)

Browser Support

Chrome Chrome
29 +
28
27
26
25
24
23
22
21
↑ Requires prefix '-webkit-'
20 and earlier ×
Firefox Firefox
28 +
27 and earlier ×
Safari Safari
9 +
8
7
↑ Requires prefix '-webkit-'
6 and earlier ×
Edge Edge
12 +
Supported in all versions.
IE IE
11
10 ×
9 ×
8 ×
7 ×
6 ×
Opera Opera
16 +
15
↑ Requires prefix '-webkit-'
14 and earlier ×
iOS Safari iOS Safari
9 +
8
7
↑ Requires prefix '-webkit-'
6 and earlier ×
Android Android Browser
4.4 +
3 and earlier ×
Chrome Android Chrome Android
Latest
Same support as desktop version
Firefox Android Firefox Android
Latest
Same support as desktop version

* Version information is based on MDN / Can I Use .

Description

The 'align-content' property is specified on a flex container to control the alignment of all rows along the cross axis when items wrap into multiple lines (when 'flex-wrap: wrap' causes wrapping). It has no effect when there is only a single line ('flex-wrap: nowrap').

各Valueの配置イメージ

flex-start center space-between align-items = alignment within a row A (tall) B C D align-content = placement of all rows Controls row spacing

Difference from align-items

The 'align-items' property controls how items are aligned within each row, while 'align-content' controls how the rows themselves are positioned within the container.

PropertyTargetEffect
align-itemsItems within a rowAligns the cross-axis position of each item.
align-contentAll rowsControls how multiple rows are positioned within the container.

Pattern: Grid-like Layout

Grid-like layout packed to the top with align-content: flex-start Card 1 Card 2 Card 3 Card 4 Card 5 Card 6 flex-start: packed to top, space below

/* Wrap cards and distribute evenly */
.grid-like {
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;  /* Pack to the top */
    gap: 16px;
    height: 500px;
}
.card {
    flex: 0 0 calc(33.333% - 16px);
}

Effectがない場合のチェックポイント

If 'align-content' is not working, check the following three points.

1つ目は『flex-wrap: wrap』が指定されているか。『nowrap』(初期Value)のままでは行が一つしかないためEffectがありません。2つ目はコンテナに交差軸方向のサイズが指定されているか。『flex-direction: row』の場合は『height』が必要です。3つ目は実際に折り返しが発生しているか。アイテムが一行に収まっている場合はEffectがありません。

関連Property

PropertyDescription
align-itemsItems within a rowの交差軸方向の揃え方を制御します。All rowsの配置は『align-content』で行います。
flex-wrap折り返しを制御します。『align-content』は『wrap』で折り返しが発生した場合にのみEffectがあります。
justify-contentControls item alignment along the main axis. 'align-content' is the cross-axis equivalent for row alignment.

If you find any errors or copyright issues, please .