My flex container has justify-content: flex-start, but I want to center the items inside it.
EDIT: For reference, I'd like it to resemble the video recommendations on the YouTube homepage.
Here is my code that doesn't seem to be working as expected:
.parent {
width: 100%;
margin: 0 auto;
max-width: 500px;
}
.child {
display: flex;
flex-wrap: wrap;
flex-direction: row;
justify-content: flex-start;
}
.item {
background-color: #4d4d4d;
margin: 5px;
width: 125px;
height: 100px;
}
This is what I'm aiming for (not exactly centered, but with flex-start and margin set to auto):
.parent {
width: 100%;
margin-left: 15%;
max-width: 500px;
}
.child {
display: flex;
flex-wrap: wrap;
flex-direction: row;
justify-content: flex-start;
}
.item {
background-color: #4d4d4d;
margin: 5px;
width: 100px;
height: 100px;
}
Thank you for your help!