The justify-content
and align-content
properties can be applied only to the flex container, but impact only flex items. So to center the container you would have to apply justify-content: center
to the parent of .flex-container
(body
, in this case).
Alternatively, you could simply use auto
margins on .flex-container
.
The align-content
property works along the cross-axis of the flex container (the vertical plane, in this case) and isn't necessary to fix your layout.
Try this:
body {
display: flex;
justify-content: center;
}
.flex-container {
display: flex;
justify-content: flex-start;
flex-wrap: wrap;
}
modified plunker demo
OR THIS:
.flex-container {
display: flex;
justify-content: flex-start;
flex-wrap: wrap;
margin: 0 auto;
}
modified plunker demo
UPDATE (based on comments)
To address the issue of extra whitespace along the right side of the container, see here: