align-items

  • Revision slug: CSS/align-items
  • Revision title: align-items
  • Revision id: 317415
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment

Revision Content

{{ CSSRef() }}

Summary

The CSS align-items property aligns flex items of the current flex line the same way as justify-content but in the perpendicular direction.

  • {{ Xref_cssinitial() }} {{cssinitial("align-items")}}
  • Applies to flex containers
  • {{ Xref_cssinherited() }} no
  • Media {{ Xref_cssvisual() }}
  • {{ Xref_csscomputed() }} {{ Xref_cssspecifiedkeyword() }}
  • {{ Xref_cssanimatable() }} {{ Xref_cssnotanimatable() }}
  • {{ Xref_csscanonicalorder() }}{{ Xref_cssuniqueorder() }}

See Using CSS flexible boxes for more properties and information.

Syntax

Formal syntax: {{csssyntax("align-items")}}
align-items: flex-start
align-items: flex-end
align-items: center
align-items: baseline
align-items: stretch

align-items: inherit

Values

flex-start
The cross-start margin edge of the flex item is flushed with the cross-start edge of the line.
flex-end
The cross-end margin edge of the flex item is flushed with the cross-end edge of the line.
center
The flex item's margin box is centered within the line on the cross-axis. If the cross-size of the item is larger than the flex container, it will overflow equally in both directions.
baseline
All flex items are aligned such that their baselines align. The item with the largest distance between its cross-start margin edge and its baseline is flushed with the cross-start edge of the line.
stretch
Flex items are stretched such as the cross-size of the item's margin box is the same as the line while respecting width and height constraints.

Examples

 

Specifications

Specification Status Comment
{{ SpecName('CSS3 Flexbox', '#align-items', 'align-items') }} {{ Spec2('CSS3 Flexbox') }}  

Browser compatibility

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 21.0{{ property_prefix("-webkit") }} {{ CompatGeckoDesktop("18.0") }}{{ property_prefix("-moz") }} (behind a pref) {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }}
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }}

See also

Revision Source

<p>{{ CSSRef() }}</p>
<h2 id="Summary">Summary</h2>
<p>The <a href="/en-US/docs/CSS" title="CSS">CSS</a> <code>align-items</code> property aligns flex items of the current flex line the same way as <a href="/en/CSS/justify-content" title="en/CSS/justify-content"><code>justify-content</code></a> but in the perpendicular direction.</p>
<ul class="cssprop">
  <li><dfn>{{ Xref_cssinitial() }}</dfn> {{cssinitial("align-items")}}</li>
  <li><dfn>Applies to</dfn> flex containers</li>
  <li><dfn>{{ Xref_cssinherited() }}</dfn> no</li>
  <li><dfn>Media</dfn> {{ Xref_cssvisual() }}</li>
  <li><dfn>{{ Xref_csscomputed() }}</dfn> {{ Xref_cssspecifiedkeyword() }}</li>
  <li><dfn>{{ Xref_cssanimatable() }}</dfn> {{ Xref_cssnotanimatable() }}</li>
  <li><dfn>{{ Xref_csscanonicalorder() }}</dfn>{{ Xref_cssuniqueorder() }}</li>
</ul>
<p>See&nbsp;<a href="/en/CSS/Using_CSS_flexible_boxes" title="/en/CSS/Using_CSS_flexible_boxes">Using CSS flexible boxes</a>&nbsp;for more properties and information.</p>
<h2 id="Syntax">Syntax</h2>
<pre class="twopartsyntaxbox">
<a href="/en-US/docs/CSS/Value_definition_syntax" title="/en-US/docs/">Formal syntax</a>: {{csssyntax("align-items")}}
</pre>
<pre>
align-items: flex-start
align-items: flex-end
align-items: center
align-items: baseline
align-items: stretch

align-items: inherit
</pre>
<h3 id="Values">Values</h3>
<dl>
  <dt>
    <code>flex-start</code></dt>
  <dd>
    The cross-start margin edge of the flex item is flushed with the cross-start edge of the line.</dd>
  <dt>
    <code>flex-end</code></dt>
  <dd>
    The cross-end margin edge of the flex item is flushed with the cross-end edge of the line.</dd>
  <dt>
    <code>center</code></dt>
  <dd>
    The flex item's margin box is centered within the line on the cross-axis. If the cross-size of the item is larger than the flex container, it will overflow equally in both directions.</dd>
  <dt>
    <code>baseline</code></dt>
  <dd>
    All flex items are aligned such that their baselines align. The item with the largest distance between its cross-start margin edge and its baseline is flushed with the cross-start edge of the line.</dd>
  <dt>
    <code>stretch</code></dt>
  <dd>
    Flex items are stretched such as the cross-size of the item's margin box is the same as the line while respecting width and height constraints.</dd>
</dl>
<h2 id="Examples">Examples</h2>
<pre>
&nbsp;</pre>
<h2 id="Specifications" name="Specifications">Specifications</h2>
<table class="standard-table">
  <thead>
    <tr>
      <th scope="col">Specification</th>
      <th scope="col">Status</th>
      <th scope="col">Comment</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>{{ SpecName('CSS3 Flexbox', '#align-items', 'align-items') }}</td>
      <td>{{ Spec2('CSS3 Flexbox') }}</td>
      <td>&nbsp;</td>
    </tr>
  </tbody>
</table>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<p>{{ CompatibilityTable() }}</p>
<div id="compat-desktop">
  <table class="compat-table">
    <tbody>
      <tr>
        <th>Feature</th>
        <th>Chrome</th>
        <th>Firefox (Gecko)</th>
        <th>Internet Explorer</th>
        <th>Opera</th>
        <th>Safari</th>
      </tr>
      <tr>
        <td>Basic support</td>
        <td>21.0{{ property_prefix("-webkit") }}</td>
        <td>{{ CompatGeckoDesktop("18.0") }}{{ property_prefix("-moz") }} (behind a pref)</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
      </tr>
    </tbody>
  </table>
</div>
<div id="compat-mobile">
  <table class="compat-table">
    <tbody>
      <tr>
        <th>Feature</th>
        <th>Android</th>
        <th>Chrome for Android</th>
        <th>Firefox Mobile (Gecko)</th>
        <th>IE Mobile</th>
        <th>Opera Mobile</th>
        <th>Safari Mobile</th>
      </tr>
      <tr>
        <td>Basic support</td>
        <td>{{ CompatUnknown() }}</td>
        <td>{{ CompatUnknown() }}</td>
        <td>{{ CompatUnknown() }}</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
      </tr>
    </tbody>
  </table>
</div>
<h2 id="See_also">See also</h2>
<ul>
  <li><a href="/en-US/docs/CSS/Using_CSS_flexible_boxes" title="/en-US/docs/CSS/Using_CSS_flexible_boxes">Using CSS flexible boxes</a></li>
  <li>{{ CSS_Reference:FlexBox() }}</li>
</ul>
Revert to this revision