0

enter image description here

Grey is container and childs are Red.

<div class="container">
    <div class="child">
    <div class="child">
    <div class="child">
</div>

EDIT: I might add those are the same elements in different widths, first one is mobile size display and the other one is medium to full size.

1 Answers1

5

Here you go:

body {
  margin: 0;
  padding: 0;
}

* {
  box-sizing: border-box;
}

.container {
  padding: 60px;
  width: 100%;
  height: 300px;
  background: grey;
  display: flex;
  flex-flow: column wrap;
  gap: 20px;
  min-height: 100vh;
}

.child {
  background: red;
  flex-grow: 1;
}

.child:nth-child(2) {
  height: 100%;
  order: -1;
}

@media only screen and (max-width: 600px) {
  .container {
    flex-flow: column;
  }

  .child:nth-child(2) {
    height: auto;
    order: initial;
  }
}
<div class="container">
  <div class="child">1</div>
  <div class="child">2</div>
  <div class="child">3</div>
</div>
dantheman
  • 3,189
  • 2
  • 10
  • 18