Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flex wrap - stack rows without stretch? [duplicate]

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>
like image 751
Kirk Ross Avatar asked Sep 15 '26 08:09

Kirk Ross


1 Answers

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>
like image 146
Temani Afif Avatar answered Sep 16 '26 23:09

Temani Afif



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!