If you prefer, you can utilize the grid
property. However, keep in mind that if you aim for just two rows, the child elements may overflow.
.parent {
display: grid;
grid-auto-flow: column;
grid-template-rows: 1fr 1fr;
overflow-x: auto;
}
To address this issue, consider using the flex
property with a specified height
for the .parent
element.
.container {
width: 600px;
margin-left: auto;
margin-right: auto;
border: 2px solid;
overflow-x: auto;
}
.parent {
height: 100px;
display: flex;
flex-flow:column wrap;
justify-content: space-between;
}
.child {
margin: 5px;
flex-basis: 35%;
background-color: blue;
}
<div class="container">
<div class="parent">
<span class="child">1 loremnxckvxckhv</span>
<span class="child">2 loremnxckvxckhv</span>
<span class="child">3 loremnxckvxckhv</span>
<span class="child">4 loremnxckvxckhv</span>
<span class="child">5 loremnxckvxckhv</span>
<span class="child">6 loremnxckvxckhv</span>
<span class="child">7 loremnxckvxckhv</span>
<span class="child">8 loremnxckvxckhv</span>
<span class="child">9 loremnxckvxckhv</span>
<span class="child">2 loremnxckvxckhv</span>
<span class="child">3 loremnxckvxckhv</span>
<span class="child">4 loremnxckvxckhv</span>
<span class="child">5 loremnxckvxckhv</span>
<span class="child">6 loremnxckvxckhv</span>
<span class="child">7 loremnxckvxckhv</span>
<span class="child">8 loremnxckvxckhv</span>
<span class="child">9 loremnxckvxckhv</span>
</div>
</div>