I have a container div
with many child div
having fixed width. I am using flexbox
to align the child divs in a single row. Below html and css works except that the first and last child are still overflowing the container div. I want the child divs to be wrapped in single row using a horizontal scroll -
.container {
display: flex;
justify-content: center;
width: 500px;
height: 200px;
background-color: gray;
overflow-x: auto;
}
.child {
margin: 5px;
min-width: 100px;
height: 150px;
background-color: darkgray;
}
<div class="container">
<div class="child"> </div>
<div class="child"> </div>
<div class="child"> </div>
<div class="child"> </div>
<div class="child"> </div>
<div class="child"> </div>
</div>
Please see this codepen I've created.