mozilla
Your Search Results

    justify-content Redirect 1

    Summary

    The CSS justify-content property defines how a browser distributes available space between and around elements when aligning flex items in the main-axis of the current line. The alignment is done after the lengths and auto margins are applied, meaning that, if there is at least one flexible element, with flex-grow different than 0, it will have no effect as there won't be any available space.

    Do not assume that this property will only apply on flex containers in the future and therefore do not simply hide it by setting another display value. The CSSWG is working into extending its usage to any block element. The draft specification is still in its very early stage and isn't implement yet.

    See Using CSS flexible boxes for more properties and information.

    Syntax

    Formal syntax: flex-start | flex-end | center | space-between | space-around
    
    justify-content: flex-start
    justify-content: flex-end
    justify-content: center
    justify-content: space-between
    justify-content: space-around
    
    justify-content: inherit
    

    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 Candidate Recommendation  

    Browser compatibility

    Feature Firefox (Gecko) Chrome Internet Explorer Opera Safari
    Basic support 18.0 (18.0) (behind a pref) [1]
    20.0 (20.0)
    21.0-webkit Not supported 12.10 Not supported
    Feature Firefox Mobile (Gecko) Android IE Phone Opera Mobile Safari Mobile
    Basic support ? ? Not supported 12.10 Not supported

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

    See also

    Document Tags and Contributors

    Contributors to this page: Sheppy
    Last updated by: Sheppy,
    Hide Sidebar