I want to be able to reverse the order of columns (the 2 small to the left, the big one right). I've tried several solutions but didn't find one that works.

Here's the code:
.images-block-box{
    display: grid;
    grid-gap: 16px;
    grid-template-columns: 708fr 340fr;
    & > div:first-child{
      grid-row: span 2;
    }
    &.reverse{
      grid-template-columns: 340fr 708fr;
      & > div:first-child{
         order: 2; // doesn't work (I want to place the first item at the end of the 3)
      }
    }// reverse
}// images-block-box
Note that I really want to reverse the order of the columns themselves, not just their dimensions.
Simply adjust grid-column and conisder grid-auto-flow:dense; to allow the next elements to be placed before:
.grid {
  display: grid;
  grid-gap: 16px;
  grid-template-columns: 2fr 1fr;
  grid-auto-flow:dense;
  margin:5px;
}
.grid div {
  min-height: 50px;
  border: 1px solid;
}
.grid div:first-child {
  grid-row: span 2;
}
.grid.reverse {
  grid-template-columns: 1fr 2fr;
}
.grid.reverse div:first-child {
  grid-column:2;
}
<div class="grid">
  <div></div>
  <div></div>
  <div></div>
</div>
<div class="grid reverse">
  <div></div>
  <div></div>
  <div></div>
</div>
dense
If specified, the auto-placement algorithm uses a “dense” packing algorithm, which attempts to fill in holes earlier in the grid if smaller items come up later. This may cause items to appear out-of-order, when doing so would fill in holes left by larger items.ref
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With