3

I have a flex container with two children of fixed dimensions that are aligned flex-end (the bottom of the parent).

When I resize the parent I want them to wrap on top of each other, but instead they each take up 50% of the parent height.

Is there a way to do this without adding another div?

FIDDLE

.wrapper {
  width: 600px;
  height: 500px;
  display: flex;
  flex-direction: row;
  justify-content: flex-start;
  align-items: flex-end;
  background-color: #eeeeee;
  resize: horizontal;
  overflow: auto;
  flex-wrap: wrap;
}

.one {
  width: 200px;
  height: 100px;
  background: red;
}

.two {
  width: 200px;
  height: 100px;
  background: blue;
}
<div class="wrapper">
  <div class="one">1</div>
  <div class="two">2</div>
</div>
kukkuz
  • 41,512
  • 6
  • 59
  • 95
Kirk Ross
  • 6,413
  • 13
  • 61
  • 104

1 Answers1

1

You need to also consider align-content like below:

.wrapper {
  width: 600px;
  height: 500px;
  display: flex;
  flex-direction: row;
  justify-content: flex-start;
  align-content:flex-end; /*added this*/
  align-items: flex-end;
  background-color: #eeeeee;
  resize: horizontal;
  overflow: auto;
  flex-wrap: wrap;
}

.one {
  width: 200px;
  height: 100px;
  background: red;
}

.two {
  width: 200px;
  height: 100px;
  background: blue;
}
<div class="wrapper">
  <div class="one">1</div>
  <div class="two">2</div>
</div>
Temani Afif
  • 245,468
  • 26
  • 309
  • 415