0

I have this code here:

#wrapper {
  height: 250px;
  position: relative;
}

#container {
  padding: 1%;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  flex-wrap: wrap;
  background-color: gray;
  height: 100%;
}

.item {
  background: skyblue;
  margin: 0 0 1em 1em;
  padding: 1%;
  height: fit-content;
}
<div id="wrapper">
  <div id="container">
    <div class="item">Really really really really really really long</div>
    <div class="item">Short</div>
    <div class="item">Short</div>
    <div class="item">Short</div>
    <div class="item">Short</div>
    <div class="item">Short</div>
    <div class="item">Short</div>
    <div class="item">Short</div>
    <div class="item">Short</div>
    <div class="item">Short</div>
    <div class="item">Short</div>
  </div>
</div>

As you can see, there is some blank space in front of the second and the third columns.

Is there any way to get rid of that?


Edit: Here is the produced result (Chrome 84): Produced result

What I hope to see: Need

1 Answers1

1

Does adding align-content: flex-end; to #container do what you want?

#wrapper {
  height: 250px;
  position: relative;
}

#container {
  padding: 1%;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  align-content: flex-end;
  flex-wrap: wrap;
  background-color: gray;
  height: 100%;
}

.item {
  background: skyblue;
  margin: 0 0 1em 1em;
  padding: 1%;
  height: fit-content;
}
<div id="wrapper">
  <div id="container">
    <div class="item">Really really really really really really long</div>
    <div class="item">Short</div>
    <div class="item">Short</div>
    <div class="item">Short</div>
    <div class="item">Short</div>
    <div class="item">Short</div>
    <div class="item">Short</div>
    <div class="item">Short</div>
    <div class="item">Short</div>
    <div class="item">Short</div>
    <div class="item">Short</div>
  </div>
</div>
EvanMorrison
  • 1,212
  • 8
  • 13