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-items

align-items

Specifies how items are aligned along the cross axis of a flex container. For 'flex-direction: row', this controls vertical alignment; for 'column', it controls horizontal alignment.

Sample Code

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

/* Align to top */
.container-start { display: flex; align-items: flex-start;}

/* Center alignment */
.container-center { display: flex; align-items: center;}

/* Align to bottom */
.container-end { display: flex; align-items: flex-end;}

/* Align to text baseline */
.container-base { display: flex; align-items: baseline;}

Available Values

ValueDescription
stretchアイテムをコンテナの交差軸方向いっぱいに伸ばします。初期Valueです。
flex-startAligns items to the start of the cross axis.
flex-endAligns items to the end of the cross axis.
centerCenters items along the cross axis.
baselineAligns items to the text baseline (the bottom edge of characters) within the items.

Specification

PropertyDetails
初期Valuestretch
Applies toFlex containers (elements with 'display: flex' or 'display: inline-flex')
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
20 +
19 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-items' property is specified on a flex container to control item alignment along the cross axis (vertical when 'flex-direction: row'). The 'justify-content' property handles the main axis, while 'align-items' handles the cross axis.

各Valueの配置イメージ

stretch A B C Heights equalized flex-start A (tall) B C center A (tall) B C flex-end A (tall) B C baseline A B C Baseline

stretch(初期Value)

アイテムにサイズ(『height』や『width』)が明示的に指定されていない場合、コンテナの交差軸方向いっぱいに引き伸ばされます。これが初期Valueであるため、『display: flex』を指定しただけでアイテムのHeights equalizedのはこのPropertyの効果です。アイテムに明示的なサイズが指定されている場合は『stretch』でも伸ばされません。

center

Centers items along the cross axis.『justify-content: center』と組み合わせることで、上下左右の完全な中央配置が実現できます。これはFlexboxの最も代表的な使い方の一つです。

/* Perfect centering in all directions */
.perfect-center {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

baseline

各アイテム内のテキストのBaseline(文字の底辺の線)を揃えます。フォントサイズが異なるアイテムが混在する場合に、テキストの位置を自然に揃えたいときに使います。

/* Align text positions of elements with different font sizes */
.nav {
    display: flex;
    align-items: baseline;
}
.nav-title { font-size: 24px;}
.nav-link { font-size: 14px;}

Changing Alignment for Individual Items

To change the cross-axis alignment for a specific item only, use the 'align-self' property on that item. The 'align-items' property is a bulk setting for the entire container, while 'align-self' is for individual items.

.container {
    display: flex;
    align-items: flex-start;  /* All items align to top */
}
.special-item {
    align-self: flex-end;  /* Only this item aligns to bottom */
}

Related Properties

PropertyDescription
justify-contentControls item alignment along the main axis. Can be combined with 'align-items' to control alignment in all directions.
align-selfSpecifies the cross-axis alignment for individual items. Overrides 'align-items'.
align-contentControls row spacing when there are multiple lines. 'align-items' handles item alignment within a row, while 'align-content' handles the positioning of all rows.
flex-direction主軸の方向を指定します。『align-items』が効く方向はこのPropertyのValueによって変わります。

If you find any errors or copyright issues, please .