justify-content

  • Revision slug: CSS/justify-content
  • Revision title: justify-content
  • Revision id: 235090
  • Created:
  • Creator: FredB
  • Is current revision? No
  • Comment one or more formatting changes

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.

<style type="text/css"></style>
  • {{ Xref_cssinitial() }}: flex-start
  • Applies to: flex containers
  • {{ Xref_cssinherited() }}: no
  • Media: {{ Xref_cssvisual() }}
  • {{ Xref_csscomputed() }}: as specified

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

{{ CompatibilityTable() }}

Feature Firefox (Gecko) Chrome Internet Explorer Opera Safari
Basic support {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }}
Feature Firefox Mobile (Gecko) Android IE Mobile Opera Mobile Safari Mobile
Basic support {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }}

See also

Revision Source

<p>{{ CSSRef() }}</p>
<p>{{ SeeCompatTable() }}</p>
<h2>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>
<nobr>
<style type="text/css"><![CDATA[.cssprop {
  display:table;
  padding: 0.4em;
  border-left:0.15em solid;
  background-color:#eeeeff
}
.cssprop li {
 display:table-row;
 padding: 3px;
 margin:0;
}
.cssprop li dfn {
  display:table-cell;
  padding: 0 5px;
  border-bottom: none;
  cursor:inherit;
}






]]></style>
<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>
</nobr>
<p><nobr></nobr></p><h2><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>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>Examples</h2>
<pre> </pre>
<h2 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>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>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</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 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>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> </tr> </tbody> </table>
</div>
<h2>See also</h2>
</nobr><p><nobr></nobr><nobr></nobr></p>
Revert to this revision