The CSS align-content
property aligns a flex container's lines within the flex container when there is extra space on the cross-axis.
This property has no effect on single line flexible boxes.
Initial value | stretch |
---|---|
Applies to | multi-line flex containers |
Inherited | no |
Media | visual |
Computed value | as specified |
Animation type | discrete |
Canonical order | the unique non-ambiguous order defined by the formal grammar |
See Using CSS flexible boxes for more properties and information.
/* Pack lines from the cross-axis start */ align-content: flex-start; /* Pack lines to the cross-axis end */ align-content: flex-end; /* Pack lines around the cross-axis center */ align-content: center; /* Distribute lines along the cross-axis, start to end */ align-content: space-between; /* Distribute lines along the cross-axis, equally spaced */ align-content: space-around; /* Stretch lines to occupy the whole cross-axis */ align-content: stretch; /* Global values */ align-content: inherit; align-content: initial; align-content: unset;
flex-start
flex-end
center
space-between
space-around
stretch
flex-start | flex-end | center | space-between | space-around | stretch
#container { display: flex; height:200px; width: 240px; flex-wrap: wrap; background-color: #8c8c8c; align-content: flex-end; /* Can be changed in the live sample */ } div > div { border: 2px solid #8c8c8c; width: 50px; height: 50px; background-color: #a0c8ff; }
<div id="container"> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> </div> <select id="contentAlignment"> <option value="flex-start">flex-start</option> <option value="flex-end" selected>flex-end</option> <option value="center">center</option> <option value="space-between">space-between</option> <option value="space-around">space-around</option> <option value="stretch">stretch</option> </select>
Specification | Status | Comment |
---|---|---|
CSS Flexible Box Layout Module The definition of 'align-content' in that specification. | Candidate Recommendation | Initial definition |
Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic support | 21.0-webkit 29.0 |
(Yes)-webkit (Yes) | 28.0 (28.0)[2] | 11 | 12.10 | 6.1-webkit 9.0 |
Feature | Android | Chrome for Android | Edge | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|---|
Basic support | 4.4 | (Yes) |
(Yes)-webkit (Yes) | 28.0 (28.0)[2] | 11.0 | 12.10 | 7.1-webkit 9.2 |
[1] In addition to the unprefixed support, Gecko 48.0 (Firefox 48.0 / Thunderbird 48.0 / SeaMonkey 2.45) added support for a -webkit
prefixed version of the property for web compatibility reasons behind the preference layout.css.prefixes.webkit
, defaulting to false
. Since Gecko 49.0 (Firefox 49.0 / Thunderbird 49.0 / SeaMonkey 2.46) the preference defaults to true
.
© 2005–2017 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/align-content