I have a simple grid layout in Bootstrap 5 like this:
<div class="row row-cols-1 row-cols-sm-2 row-cols-lg-3">
<div class="col border">Field1</div>
<div class="col border">Field2</div>
<div class="col border">Field3</div>
<div class="col border">Field4</div>
<div class="col border">Field5</div>
<div class="col border">Field6</div>
<div class="col border">Field7</div>
<div class="col border">Field8</div>
<div class="col border">Field9</div>
</div>
Depending on the screen width, it looks like this:
Large Medium Small
[ 1 ] [ 2 ] [ 3 ] [ 1 ] [ 2 ] [ 1 ]
[ 4 ] [ 5 ] [ 6 ] [ 3 ] [ 4 ] [ 2 ]
[ 7 ] [ 8 ] [ 9 ] [ 5 ] [ 6 ] [ 3 ]
[ 7 ] [ 8 ] [ 4 ]
[ 9 ] [ 5 ]
...
However, I want it to be ordered vertically:
Large Medium Small
[ 1 ] [ 4 ] [ 7 ] [ 1 ] [ 6 ] [ 1 ]
[ 2 ] [ 5 ] [ 8 ] [ 2 ] [ 7 ] [ 2 ]
[ 3 ] [ 6 ] [ 9 ] [ 3 ] [ 8 ] [ 3 ]
[ 4 ] [ 9 ] [ 4 ]
[ 5 ] [ 5 ]
...
A solution I found is to use the order
class depending on the screen width, like:
<div class="col border order-4 order-sm-7 order-lg-2">Field4</div>
This seams to be a mass and error prone, if a field es added in the future.
Is this the way to go, or is there a simpler solution?