align-items

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

Revision Content

{{ CSSRef() }}

{{ SeeCompatTable() }}

Summary

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

  • {{ Xref_cssinitial() }}: stretch
  • Applies to: flex containers
  • {{ Xref_cssinherited() }}: no
  • Media: {{ Xref_cssvisual() }}
  • {{ Xref_csscomputed() }}: as specified
  • {{ Xref_cssanimatable() }}: no
  • {{ Xref_csscanonicalorder() }}: the unique non-ambiguous order defined by the formal grammar

See Using CSS flexible boxes for more properties and information.

Syntax

Formal grammar: <align-items> 
                where <align-items> is flex-start | flex-end | center | baseline | stretch
align-items: flex-start
align-items: flex-end
align-items: center
align-items: baseline
align-items: stretch

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 Firefox (Gecko) Chrome Internet Explorer Opera Safari
Basic support {{ CompatUnknown() }} 21.0{{ property_prefix("-webkit") }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }}
Feature Firefox Mobile (Gecko) Android IE Phone Opera Mobile Safari Mobile
Basic support {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }}

See also

Revision Source

<p>{{ CSSRef() }}</p>
<p>{{ SeeCompatTable() }}</p>
<h2 id="Summary">Summary</h2>
<p>The <code>align-items</code> <a href="/en/CSS" title="CSS">CSS</a> 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> <code>stretch</code></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> as specified</li>
  <li><dfn>{{ Xref_cssanimatable() }}:</dfn> no</li>
  <li><dfn>{{ Xref_csscanonicalorder() }}:</dfn> the unique non-ambiguous order defined by the formal grammar</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">
Formal grammar: &lt;align-items&gt; 
&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; where &lt;align-items&gt; is flex-start | flex-end | center | baseline | stretch
</pre>
<pre>
align-items: flex-start
align-items: flex-end
align-items: center
align-items: baseline
align-items: stretch
</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>Firefox (Gecko)</th>
        <th>Chrome</th>
        <th>Internet Explorer</th>
        <th>Opera</th>
        <th>Safari</th>
      </tr>
      <tr>
        <td>Basic support</td>
        <td>{{ CompatUnknown() }}</td>
        <td>21.0{{ property_prefix("-webkit") }}</td>
        <td>{{ CompatUnknown() }}</td>
        <td>{{ CompatUnknown() }}</td>
        <td>{{ CompatUnknown() }}</td>
      </tr>
    </tbody>
  </table>
</div>
<table class="compat-table">
  <tbody>
    <tr>
      <th>Feature</th>
      <th>Firefox Mobile (Gecko)</th>
      <th>Android</th>
      <th>IE&nbsp;Phone</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>{{ CompatUnknown() }}</td>
      <td>{{ CompatUnknown() }}</td>
    </tr>
  </tbody>
</table>
<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 flexible boxes</a></li>
  <li>{{ CSS_Reference:FlexBox() }}</li>
</ul>
Revert to this revision