0

I have this plunkr here. How to remove the vertical spacing while using flex-wrap: wrap;

#main {
  width: 200px;
  height: 200px;
  border: 1px solid #c3c3c3;
  display: flex;
  flex-wrap: wrap;
}
<div id="main">
  <div style="background-color:coral;">A</div>
  <div style="background-color:lightblue;">B</div>
  <div style="background-color:khaki;">C</div>
  <div style="background-color:pink;">D</div>
  <div style="background-color:lightgrey;">E</div>
  <div style="background-color:lightgreen;">F</div>
</div>
Shashank Vivek
  • 15,676
  • 8
  • 57
  • 96
User985614
  • 270
  • 3
  • 14

2 Answers2

1

You should use align-content: flex-start; on #main

Shashank Vivek
  • 15,676
  • 8
  • 57
  • 96
0

#main {
  width: 200px;
  height: 200px;
  border: 1px solid #c3c3c3;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
}
<div id="main">
  <div style="background-color:coral;">A</div>
  <div style="background-color:lightblue;">B</div>
  <div style="background-color:khaki;">C</div>
  <div style="background-color:pink;">D</div>
  <div style="background-color:lightgrey;">E</div>
  <div style="background-color:lightgreen;">F</div>
</div>
Nikita
  • 1,693
  • 1
  • 6
  • 18