flex-direction

  • Revision slug: Web/CSS/flex-direction
  • Revision title: flex-direction
  • Revision id: 518863
  • Created:
  • Creator: PifyZ
  • Is current revision? No
  • Comment

Revision Content

{{ CSSRef("CSS Flexible Boxes") }}

Summary

The CSS flex-direction property specifies how flex items are placed in the flex container defining the main axis and the direction (normal or reversed).

Note that the value row and row-reverse are affected by the directionality of the flex container. If its dir attribute is ltr, row represents the horizontal axis oriented from the left to the right, and row-reverse from the right to the left; if the dir attribute is rtl, row represents the axis oriented from the right to the left, and row-reverse from the left to the right.

{{cssbox("flex-direction")}}

See Using CSS flexible boxes for more properties and information.

Syntax

Formal syntax: {{csssyntax("flex-direction")}}
flex-direction: row
flex-direction: row-reverse
flex-direction: column
flex-direction: column-reverse

flex-direction: inherit

Values

The following values are accepted:

row
The flex container's main-axis is defined to be the same as the text direction. The main-start and main-end points are the same as the content direction.
row-reverse
Behaves the same as row but the main-start and main-end points are permuted.
column
The flex container's main-axis is the same as the block-axis. The main-start and main-end points are the same as the before and after points of the writing-mode.
column-reverse
Behaves the same as column but the main-start and main-end are permuted.

Examples

element { 
  flex-direction: row-reverse;
}

Specifications

Specification Status Comment
{{ SpecName('CSS3 Flexbox', '#flex-direction', 'flex-direction') }} {{ Spec2('CSS3 Flexbox') }}  

Browser compatibility

{{ CompatibilityTable() }}

Feature Firefox (Gecko) Chrome Internet Explorer Opera Safari
Basic support {{ CompatGeckoDesktop("18.0") }} (behind a pref) [1]
{{ CompatGeckoDesktop("20.0") }}
21.0{{ property_prefix("-webkit") }} {{ CompatNo() }} 12.10 {{ CompatNo() }}
Feature Firefox Mobile (Gecko) Android IE Phone Opera Mobile Safari Mobile
Basic support {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatNo() }} 12.10 {{ CompatNo() }}

[1] To activate flexbox support, for Firefox 18 and 19, the user has to change the about:config preference "layout.css.flexbox.enabled" to true. Firefox supports multi-line flexbox since Firefox 28.

See also

Revision Source

<p>{{ CSSRef("CSS Flexible Boxes") }}</p>
<h2 id="Summary">Summary</h2>
<p>The <a href="/en-US/docs/CSS" title="CSS">CSS</a> <code>flex-direction</code> property specifies how flex items are placed in the flex container defining the main axis and the direction (normal or reversed).</p>
<p>Note that the value <code>row</code> and <code>row-reverse</code> are affected by the directionality of the flex container. If its <code>dir</code> attribute is <code>ltr</code>, <code>row</code> represents the horizontal axis oriented from the left to the right, and <code>row-reverse</code> from the right to the left; if the <code>dir</code> attribute is <code>rtl</code>, <code>row</code> represents the axis oriented from the right to the left, and <code>row-reverse</code> from the left to the right.</p>
<p>{{cssbox("flex-direction")}}</p>
<p>See <a href="/en-US/docs/Web/Guide/CSS/Flexible_boxes" title="/en/CSS/Using_CSS_flexible_boxes">Using CSS flexible boxes</a> 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("flex-direction")}}
</pre>
<pre>
flex-direction: row
flex-direction: row-reverse
flex-direction: column
flex-direction: column-reverse

flex-direction: inherit
</pre>
<h3 id="Values">Values</h3>
<p>The following values are accepted:</p>
<dl>
 <dt>
  <code>row</code></dt>
 <dd>
  The flex container's main-axis is defined to be the same as the text direction. The <strong>main-start</strong> and <strong>main-end</strong> points are the same as the content direction.</dd>
 <dt>
  <code>row-reverse</code></dt>
 <dd>
  Behaves the same as <code>row</code> but the <strong>main-start</strong> and <strong>main-end</strong> points are permuted.</dd>
 <dt>
  <code>column</code></dt>
 <dd>
  The flex container's main-axis is the same as the block-axis. The <strong>main-start</strong> and <strong>main-end</strong> points are the same as the <strong>before</strong> and <strong>after</strong> points of the writing-mode.</dd>
 <dt>
  <code>column-reverse</code></dt>
 <dd>
  Behaves the same as <code>column</code> but the <strong>main-start</strong> and <strong>main-end</strong> are permuted.</dd>
</dl>
<h2 id="Examples">Examples</h2>
<pre class="brush:css;highlight:[2]">
element { 
  flex-direction: row-reverse;
}
</pre>
<h2 id="Specifications">Specifications</h2>
<table class="standard-table">
 <thead>
  <tr>
   <th>Specification</th>
   <th>Status</th>
   <th>Comment</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{ SpecName('CSS3 Flexbox', '#flex-direction', 'flex-direction') }}</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>{{ CompatGeckoDesktop("18.0") }} (behind a pref) [1]<br />
     {{ CompatGeckoDesktop("20.0") }}</td>
    <td>21.0{{ property_prefix("-webkit") }}</td>
    <td>{{ CompatNo() }}</td>
    <td>12.10</td>
    <td>{{ CompatNo() }}</td>
   </tr>
  </tbody>
 </table>
</div>
<div id="compat-mobile">
 <table class="compat-table">
  <tbody>
   <tr>
    <th>Feature</th>
    <th>Firefox Mobile (Gecko)</th>
    <th>Android</th>
    <th>IE Phone</th>
    <th>Opera Mobile</th>
    <th>Safari Mobile</th>
   </tr>
   <tr>
    <td>Basic support</td>
    <td>{{ CompatUnknown() }}</td>
    <td>{{ CompatUnknown() }}</td>
    <td>{{ CompatNo() }}</td>
    <td>12.10</td>
    <td>{{ CompatNo() }}</td>
   </tr>
  </tbody>
 </table>
</div>
<p>[1] To activate flexbox support, for Firefox 18 and 19, the user has to change the about:config preference "layout.css.flexbox.enabled" to <code>true</code>. Firefox supports multi-line flexbox since Firefox 28.</p>
<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