Are you familiar with CSS Grid Layout ? grid-auto-flow controls how the auto-placement algorithm works.