flexbox justify-content code example
Example 1: flexbox center and space between
.flexbox {
display: flex;
justify-content: space-between;
}
.flex-item {
margin: auto;
}
Example 2: space between flexbox
justify-content: space-between;
Example 3: justify content css
justify-content: center;
justify-content: start;
justify-content: end;
justify-content: flex-start;
justify-content: flex-end;
justify-content: left;
justify-content: right;
justify-content: normal;
justify-content: space-between;
justify-content: space-around;
justify-content: space-evenly;
justify-content: stretch;
justify-content: safe center;
justify-content: unsafe center;
justify-content: inherit;
justify-content: initial;
justify-content: unset;
Example 4: justify content
justify-content: center;
justify-content: start;
justify-content: end;
justify-content: flex-start;
justify-content: flex-end;
justify-content: left;
justify-content: right;
justify-content: normal;
justify-content: space-between;
justify-content: space-around;
justify-content: space-evenly;
justify-content: stretch;
justify-content: safe center;
justify-content: unsafe center;
justify-content: inherit;
justify-content: initial;
justify-content: unset;
Example 5: justify-content vs align-items
(Note: The X and Y axis / alignment direction can change depending
if you are using flex-direction: row or column)
1. justify-content: Horizontal-X-axis
Alignment & Spacing along primary axis (X-axis)
flex-start; Align children horizontally left
flex-end; Align children horizontally right
center; Align children horizontally centered (amaze!)
space-between; Distribute children horizontally evenly across
entire width
space-around; Distribute children horizontally evenly across
entire width (but with space on the edges
2. align-items: Vertical-Y-axis
Alignment only along secondary axis (Y-axis)
flex-start; Align children vertically top
flex-end; Align children vertically bottom
center; Align children vertically centered (amaze!)
baseline; Aligned children vertically so their baselines align
(doesn't really work)
stretch; Force children to be height of container (great for columns)
See it in action:
http://codepen.io/enxaneta/full/adLPwv/
Example 6: gap between two flex items
.upper
{
margin:30px;
display:flex;
flex-direction:row;
width:300px;
height:80px;
border:1px red solid;
padding:5px;
}
.upper > div
{
flex:1 1 auto;
border:1px red solid;
text-align:center;
margin:5px;
}
.upper.mc
{flex-direction:column;flex-wrap:wrap;width:200px;height:200px;}