justify-content

  • Revision slug: CSS/justify-content
  • Revision title: justify-content
  • Revision id: 238593
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment

Revision Content

{{ CSSRef() }}

{{ SeeCompatTable() }}

Summary

The justify-content CSS property aligns flex items in the main-axis of the current line. The alignment is done after the lengths and auto margins are applied.

  • {{ Xref_cssinitial() }}: flex-start
  • Applies to: flex containers
  • {{ Xref_cssinherited() }}: no
  • Media: {{ Xref_cssvisual() }}
  • {{ Xref_csscomputed() }}: as specified

See Using CSS flexible boxes for more properties and information.

Syntax

Formal grammar: <justify-content>
                where <justify-content> is flex-start | flex-end | center | space-between | space-around
justify-content: flex-start | flex-end | center | space-between | space-around

Values

flex-start
The flex items are packed starting from the main-start. Margins of the first flex item is flushed with the main-start edge of the line and each following flex item is flushed with the preceding.
flex-end
The flex items are packed starting from the main-end. The margin edge of the last flex item is flushed with the main-end edge of the line and each preceding flex item is flushed with the following.
center
The flex items are packed toward the center of the line. The flex items are flushed with each other and aligned in the center of the line. Space between the main-start edge of the line and first item and between main-end and the last item of the line is the same.
space-between
Flex items are evenly distributed along the line. The spacing is done such as the space between two adjacent items is the same. Main-start edge and main-end edge are flushed with respectively first and last flex item edges.
space-around
Flex items are evenly distributed so that the space between two adjacent items is the same. The empty space before the first and after the last items equals half of the space between two adjacent items.

Examples

 

Specifications

Specification Status Comment
CSS Flexible Box Layout Module {{ Spec2('CSS3 Flexbox') }}  

Browser compatibility

{{ page{path: "/en/CSS/Using_CSS_flexible_boxes", section: "Browser compatibility"} }}

See also

Revision Source

<p>{{ CSSRef() }}</p>
<p>{{ SeeCompatTable() }}</p>
<h2 id="Summary">Summary</h2>
<p>The <code>justify-content</code> <a href="/en/CSS" title="CSS">CSS</a> property aligns flex items in the main-axis of the current line. The alignment is done after the lengths and auto margins are applied.</p>
<ul class="cssprop">
  <li><dfn>{{ Xref_cssinitial() }}:</dfn><code> flex-start</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>
</ul>
<p>See <a href="/en/CSS/Using_CSS_flexible_boxes" title="/en/CSS/Using_CSS_flexible_boxes">Using CSS flexible boxes</a> for more properties and information.</p><h2 id="Syntax"><nobr>Syntax</nobr></h2><nobr>
<pre class="twopartsyntaxbox">Formal grammar: &lt;justify-content&gt;
                where &lt;justify-content&gt; is flex-start | flex-end | center | space-between | space-around
</pre>
<pre>justify-content: flex-<em>start | flex-end | center | space-between | space-around</em>
</pre>
<h3 id="Values">Values</h3>
<dl> <dt><code>flex-start</code></dt> <dd>The flex items are packed starting from the <strong>main-start</strong>. Margins of the first flex item is flushed with the main-start edge of the line and each following flex item is flushed with the preceding.</dd> <dt><code>flex-end</code></dt> <dd>The flex items are packed starting from the <strong>main-end</strong>. The margin edge of the last flex item is flushed with the main-end edge of the line and each preceding flex item is flushed with the following.</dd> <dt><code>center</code></dt> <dd>The flex items are packed toward the center of the line. The flex items are flushed with each other and aligned in the center of the line. Space between the main-start edge of the line and first item and between main-end and the last item of the line is the same.</dd> <dt><code>space-between</code></dt> <dd>Flex items are evenly distributed along the line. The spacing is done such as the space between two adjacent items is the same. Main-start edge and main-end edge are flushed with respectively first and last flex item edges.</dd> <dt><code>space-around</code></dt> <dd>Flex items are evenly distributed so that the space between two adjacent items is the same. The empty space before the first and after the last items equals half of the space between two adjacent items.</dd>
</dl>
<h2 id="Examples">Examples</h2>
<pre> </pre>
<h2 id="Specifications" name="Specifications">Specifications</h2>
<table class="standard-table"> <thead> <tr style="background-color: rgb(255, 204, 255);"> <th scope="col">Specification</th> <th scope="col">Status</th> <th scope="col">Comment</th> </tr> </thead> <tbody> <tr> <td><a class="external" href="http://dev.w3.org/csswg/css3-flexbox/#justify-content-property" title="http://dev.w3.org/csswg/css3-flexbox/#justify-content-property">CSS Flexible Box Layout Module</a></td> <td>{{ Spec2('CSS3 Flexbox') }}</td> <td> </td> </tr> </tbody>
</table>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<p>{{ page{path: "/en/CSS/Using_CSS_flexible_boxes", section: "Browser compatibility"} }}</p><h2 id="See_also">See also</h2>
</nobr><p><nobr></nobr><nobr></nobr></p>
Revert to this revision