Parent flex container properties
This property used to align the flex items.
This property horizontally aligns all flex items when items do not use all available space.
- See usage and the differences shown in the below examples.
.container {
border:3px solid #00FF00;
padding:10px;
}
.flex-item {
border:1px solid #000000;
padding:10px;
}
.container-justify-flex-start {
display: flex;
justify-content: flex-start;
}
<div class="container container-justify-flex-start">
<div class="flex-item">
ITEM 1
</div>
<div class="flex-item">
ITEM 2
</div>
<div class="flex-item">
ITEM 3
</div>
</div>
flex-start: flex items display towards start of the line. This is default value of "justify-content" property.
.container {
border:3px solid #00FF00;
padding:10px;
}
.flex-item {
border:1px solid #000000;
padding:10px;
}
.container-justify-flex-end {
display: flex;
justify-content: flex-end;
}
<div class="container container-justify-flex-end">
<div class="flex-item">
ITEM 1
</div>
<div class="flex-item">
ITEM 2
</div>
<div class="flex-item">
ITEM 3
</div>
</div>
flex-end: flex items display towards end of the line.
.container {
border:3px solid #00FF00;
padding:10px;
}
.flex-item {
border:1px solid #000000;
padding:10px;
}
.container-justify-center {
display: flex;
justify-content: center;
}
<div class="container container-justify-center">
<div class="flex-item">
ITEM 1
</div>
<div class="flex-item">
ITEM 2
</div>
<div class="flex-item">
ITEM 3
</div>
</div>
center: flex items display centered of the line.
.container {
border:3px solid #00FF00;
padding:10px;
}
.flex-item {
border:1px solid #000000;
padding:10px;
}
.container-justify-space-around {
display: flex;
justify-content: space-around;
}
<div class="container container-justify-space-around">
<div class="flex-item">
ITEM 1
</div>
<div class="flex-item">
ITEM 2
</div>
<div class="flex-item">
ITEM 3
</div>
</div>
space-around: flex items distributed evenly with equal space around the each flex item. Each item applies its own spacing.
.container {
border:3px solid #00FF00;
padding:10px;
}
.flex-item {
border:1px solid #000000;
padding:10px;
}
.container-justify-space-between {
display: flex;
justify-content: space-between;
}
<div class="container container-justify-space-between">
<div class="flex-item">
ITEM 1
</div>
<div class="flex-item">
ITEM 2
</div>
<div class="flex-item">
ITEM 3
</div>
</div>
space-between: flex items with space distributed evenly between lines, first item is on the start line and last item is on the end line.
.container {
border:3px solid #00FF00;
padding:10px;
}
.flex-item {
border:1px solid #000000;
padding:10px;
}
.container-justify-space-evenly {
display: flex;
justify-content: space-evenly;
}
<div class="container container-justify-space-evenly">
<div class="flex-item">
ITEM 1
</div>
<div class="flex-item">
ITEM 2
</div>
<div class="flex-item">
ITEM 3
</div>
</div>
space-evenly: flex items distributed in equal spacing between any two items.
This property vertically aligns all flex items when items do not use all available space.
- See usage and the differences shown in the below examples.
.container-align-content {
border:3px solid #00FF00;
padding:10px;
height: 200px;
}
.flex-item {
border:1px solid #000000;
padding:10px;
}
.container-align-items-flex-start {
display: flex;
align-items: flex-start;
align-content: center;
}
<div class="container-align-content container-align-items-flex-start">
<div class="flex-item">
ITEM 1
</div>
<div class="flex-item">
ITEM 2
</div>
<div class="flex-item">
ITEM 3
</div>
</div>
flex-start: Items inside flex container align at the top of the container.
.container-align-items {
border:3px solid #00FF00;
padding:10px;
height: 200px;
}
.flex-item {
border:1px solid #000000;
padding:10px;
}
.container-align-items-flex-end {
display: flex;
align-items: flex-end;
}
<div class="container-align-items container-align-items-flex-end">
<div class="flex-item">
ITEM 1
</div>
<div class="flex-item">
ITEM 2
</div>
<div class="flex-item">
ITEM 3
</div>
</div>
flex-end: Items inside flex container align at the bottom of the container.
.container-align-items {
border:3px solid #00FF00;
padding:10px;
height: 200px;
}
.flex-item {
border:1px solid #000000;
padding:10px;
}
.container-align-items-center {
display: flex;
align-items: center;
}
<div class="container-align-items container-align-items-center">
<div class="flex-item">
ITEM 1
</div>
<div class="flex-item">
ITEM 2
</div>
<div class="flex-item">
ITEM 3
</div>
</div>
center: Items inside flex container displays vertically centered.
.container-align-items {
border:3px solid #00FF00;
padding:10px;
height: 200px;
}
.flex-item {
border:1px solid #000000;
padding:10px;
}
.container-align-items-stretch {
display: flex;
align-items: stretch;
}
<div class="container-align-items container-align-items-stretch">
<div class="flex-item">
ITEM 1
</div>
<div class="flex-item">
ITEM 2
</div>
<div class="flex-item">
ITEM 3
</div>
</div>
stretch: All flex items are stretch to fit the container.
.container-align-items {
border:3px solid #00FF00;
padding:10px;
height: 200px;
}
.flex-item {
border:1px solid #000000;
padding:10px;
}
.container-align-items-baseline {
display: flex;
align-items: baseline;
}
<div class="container-align-items container-align-items-baseline">
<div class="flex-item">
ITEM 1
</div>
<div class="flex-item">
ITEM 2
</div>
<div class="flex-item">
ITEM 3
</div>
</div>
baseline: All flex items align at the baseline of the flex container.
This property modifies the behavior of the "flex-wrap" property. It is similar as the property of "align-items", but it aligns flex lines not flex items.
Note: This property only work is there is multiple lines of flex items. There is no effect on one line flex items.
- See usage and the differences shown in the below examples.
.container-align-content {
border:3px solid #00FF00;
padding:10px;
height: 200px;
}
.flex-item {
border:1px solid #000000;
padding:10px;
width:60px;
}
.container-align-content-flex-start {
display: -webkit-flex;
display: flex;
-webkit-flex-wrap: wrap;
flex-wrap: wrap;
-webkit-align-content: flex-start;
align-content: flex-start;
}
<div class="container-align-content container-align-content-flex-start">
<div class="flex-item">
ITEM 1
</div>
<div class="flex-item">
ITEM 2
</div>
<div class="flex-item">
ITEM 3
</div>
<div class="flex-item">
ITEM 3
</div>
<div class="flex-item">
ITEM 4
</div>
<div class="flex-item">
ITEM 5
</div>
<div class="flex-item">
ITEM 6
</div>
<div class="flex-item">
ITEM 7
</div>
<div class="flex-item">
ITEM 8
</div>
<div class="flex-item">
ITEM 9
</div>
</div>
flex-start: All lines align toward the start of the flex container.
.container-align-content {
border:3px solid #00FF00;
padding:10px;
height: 200px;
}
.flex-item {
border:1px solid #000000;
padding:10px;
width:60px;
}
.container-align-content-flex-end {
display: -webkit-flex;
display: flex;
-webkit-flex-wrap: wrap;
flex-wrap: wrap;
-webkit-align-content: flex-end;
align-content: flex-end;
}
<div class="container-align-content container-align-content-flex-end">
<div class="flex-item">
ITEM 1
</div>
<div class="flex-item">
ITEM 2
</div>
<div class="flex-item">
ITEM 3
</div>
<div class="flex-item">
ITEM 4
</div>
<div class="flex-item">
ITEM 5
</div>
<div class="flex-item">
ITEM 6
</div>
<div class="flex-item">
ITEM 7
</div>
<div class="flex-item">
ITEM 8
</div>
<div class="flex-item">
ITEM 9
</div>
</div>
flex-end: All lines align toward the end of the flex container.
.container-align-content {
border:3px solid #00FF00;
padding:10px;
height: 200px;
}
.flex-item {
border:1px solid #000000;
padding:10px;
width:60px;
}
.container-align-content-center {
display: -webkit-flex;
display: flex;
-webkit-flex-wrap: wrap;
flex-wrap: wrap;
-webkit-align-content: center;
align-content: center;
}
<div class="container-align-content container-align-content-center">
<div class="flex-item">
ITEM 1
</div>
<div class="flex-item">
ITEM 2
</div>
<div class="flex-item">
ITEM 3
</div>
<div class="flex-item">
ITEM 4
</div>
<div class="flex-item">
ITEM 5
</div>
<div class="flex-item">
ITEM 6
</div>
<div class="flex-item">
ITEM 7
</div>
<div class="flex-item">
ITEM 8
</div>
<div class="flex-item">
ITEM 9
</div>
</div>
center: All lines displays vertically centered.
.container-align-content {
border:3px solid #00FF00;
padding:10px;
height: 200px;
}
.flex-item {
border:1px solid #000000;
padding:10px;
width:60px;
}
.container-align-content-stretch {
display: -webkit-flex;
display: flex;
-webkit-flex-wrap: wrap;
flex-wrap: wrap;
-webkit-align-content: stretch;
align-content: stretch;
}
<div class="container-align-content container-align-content-stretch">
<div class="flex-item">
ITEM 1
</div>
<div class="flex-item">
ITEM 2
</div>
<div class="flex-item">
ITEM 3
</div>
<div class="flex-item">
ITEM 4
</div>
<div class="flex-item">
ITEM 5
</div>
<div class="flex-item">
ITEM 6
</div>
<div class="flex-item">
ITEM 7
</div>
<div class="flex-item">
ITEM 8
</div>
<div class="flex-item">
ITEM 9
</div>
</div>
stretch: All lines equally stretch to take up the remaining space.
.container-align-content {
border:3px solid #00FF00;
padding:10px;
height: 200px;
}
.flex-item {
border:1px solid #000000;
padding:10px;
width:60px;
}
.container-align-content-space-between {
display: -webkit-flex;
display: flex;
-webkit-flex-wrap: wrap;
flex-wrap: wrap;
-webkit-align-content: space-between;
align-content: space-between;
}
<div class="container-align-content container-align-content-space-between">
<div class="flex-item">
ITEM 1
</div>
<div class="flex-item">
ITEM 2
</div>
<div class="flex-item">
ITEM 3
</div>
<div class="flex-item">
ITEM 4
</div>
<div class="flex-item">
ITEM 5
</div>
<div class="flex-item">
ITEM 6
</div>
<div class="flex-item">
ITEM 7
</div>
<div class="flex-item">
ITEM 8
</div>
<div class="flex-item">
ITEM 9
</div>
</div>
space-between: All lines evenly distributed in the flex container.
.container-align-content {
border:3px solid #00FF00;
padding:10px;
height: 200px;
}
.flex-item {
border:1px solid #000000;
padding:10px;
width:60px;
}
.container-align-content-space-around {
display: -webkit-flex;
display: flex;
-webkit-flex-wrap: wrap;
flex-wrap: wrap;
-webkit-align-content: space-around;
align-content: space-around;
}
<div class="container-align-content container-align-content-space-around">
<div class="flex-item">
ITEM 1
</div>
<div class="flex-item">
ITEM 2
</div>
<div class="flex-item">
ITEM 3
</div>
<div class="flex-item">
ITEM 4
</div>
<div class="flex-item">
ITEM 5
</div>
<div class="flex-item">
ITEM 6
</div>
<div class="flex-item">
ITEM 7
</div>
<div class="flex-item">
ITEM 8
</div>
<div class="flex-item">
ITEM 9
</div>
</div>
space-around: All lines evenly distributed in the flex container with equal space applies around each line.