Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Making a div take 100% of width so the next go under (Flexbox)

So I want to make the blue div go under the green one but not under the red. Like the red being the aside, the green the header and the blue just some div.

<div class="wrap">
     <div class="one"></div>
     <div class="two"></div>
     <div class="three"></div>
</div> 
.wrap {
  display: flex;
  flex-wrap: wrap;
  height: 20rem;
}

.one {
  background-color: red;
  width: 20%;
  height: 100%;
}

.two {
  background-color: green;
  height: 3rem;
  flex: 1;
}

.three {
  width: 10rem;
  height: 10rem;
  background-color: blue;
}

I’ve tried with flex, flex-basis, flex-wrap, flex-grow, but none worked for me.

Codepen: https://codepen.io/eduardomirand/pen/dywWKGL

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can’t do it with flex and your markup. You should use Grid or if you want use only Flexbox do following:

<div class="wrap">
     <div class="one"></div>
     <div class="innerWrap">
       <div class="two"></div>
       <div class="three"></div>
     </div>
</div> 

and add CSS:

.innerWrap {
  display: flex;
  flex-direction: column;
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading