2

I am trying to style my elements so that it looks something like this. (The square elements should all be same size)

enter image description here

But what ends up happening is this: enter image description here

This is my css code for the container and elements:

.container {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-between;
    height: 400px;
}

.element {
    width: 80px;
    height: 80px;
    background-color: white;
}
Michael Benjamin
  • 346,931
  • 104
  • 581
  • 701
dylanpark
  • 129
  • 9
  • Just remove justify-content:space between and you can add margin around the elements. –  Dec 18 '17 at 22:54

1 Answers1

0

Add align-content: flex-start to the .container style.

This aligns a flex container's lines within when there is extra space in the cross-axis, similar to how justify-content aligns individual items within the main-axis.

More info about align-content.

Decade Moon
  • 32,968
  • 8
  • 81
  • 101