0

.container {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  column-gap: 63px;
}
.container:after {
  content: "";
  flex: auto;
}
<div class="container">
        <div class="item"></div>
        <div class="item"></div>
        <div class="item"></div>
    </div>

I'm trying to set up a page that shows all the site contributors in a grid;
I'm using this basic structure:

Horizontal space between columns, which is at least 63px (as column-right value), is automatically increased by justify-content: space-between
I'm using :after selector in order to align the elements of the last row to the left, but when the space between columns is increased by justify-content, the last row items (except for the first one) are vertically misaligned.
Here you can see a screenshot which better explain what I'm referring to.
Any suggestion will be appreciated :)

Ahmad MRF
  • 1,346
  • 1
  • 6
  • 16
Enrico
  • 7
  • 1

1 Answers1

0

you can use grid to solve it.

.container {
  display: grid;
  gap: 24px;
  grid-template-columns: repeat(auto-fill , minmax(100px,1fr));
  justify-items: center;
}
.item {
  width: 100px;
  height: 100px;
  background: red;
}
<div class="container">
        <div class="item"></div>
        <div class="item"></div>
        <div class="item"></div> 
        <div class="item"></div>
        <div class="item"></div>
        <div class="item"></div>
        <div class="item"></div>
        <div class="item"></div>
        <div class="item"></div>
    </div>
Ahmad MRF
  • 1,346
  • 1
  • 6
  • 16