I have a bootstrap 4.1 app. I'm trying to layout a set of 6 cards.
On a wide (landscape) display I want to display 2 rows of 3 columns.
[1] [2] [3]
[4] [5] [6]
But on a narrow (portrait) display, I want to display 3 rows of 2 columns and I want the cards to maintain order going down the column, like this:
[1] [4]
[2] [5]
[3] [6]
The problem I'm having is that it doesn't seem to honor the col-* when the grid is in column direction and I get this:
[1]
[2]
[3]
[4]
[5]
[6]
Here's my markup:
<div class="container">
<div class="row flex-column flex-md-row">
<div class="card col-6 col-md-4">
<h5 class="card-header">Card 1</h5>
<div class="card-body"></div>
</div>
<div class="card col-6 col-md-4">
<h5 class="card-header">Card 2</h5>
<div class="card-body"></div>
</div>
<div class="card col-6 col-md-4">
<h5 class="card-header">Card 3</h5>
<div class="card-body"></div>
</div>
<div class="card col-6 col-md-4">
<h5 class="card-header">Card 4</h5>
<div class="card-body"></div>
</div>
<div class="card col-6 col-md-4">
<h5 class="card-header">Card 5</h5>
<div class="card-body"></div>
</div>
<div class="card col-6 col-md-4">
<h5 class="card-header">Card 6</h5>
<div class="card-body"></div>
</div>
</div>
</div>
On the div with the row class I'm defaulting to flex-column to get the columnar direction at narrow widths. I switch to row direction at medium size. That seems to work. On each card div I default to col-6 to get only two columns at small widths and switch to col-4 at medium size to get 3 columns with wider displays.
With wider displays, the grid honors the number of columns. At narrow widths, nothing forces the cards to a second column. What's the best way to handle that?
flex-columnclass for smaller widths, that should display everything as intended, and then to reorder your cards in the way you need, you can define aorder-*class on your columns - IvanS95flex-columnwill keep expanding the row indefinitely since the viewport can grow with it: codepen.io/IvanS95/pen/aQjBdz - IvanS95rowis by default set to row for display purposes. - Jhecht