I am attempting to create a scheme where I have a big vertical div of 2h height with a big horizontal div next to it in the first h of height and then in the second h of height I’d like to have another smaller div. I’d like it to look like so:
But unfortunately all I am capable of achieving is this:
I am unsure of why the third div is being positioned below the first rather than besides it.
Some additional rules I am unfortunately incapable of applying in my actual case:
- I cannot wrap any of the div’s individually in another container
- I cannot use absolute positioning since in my actual use case I am generating the divs dynamically.
Here is the simple example I reproduced.
.container {
display: flex;
flex-wrap: wrap;
}
.first {
background-color: #0afc12;
flex-basis: 33%;
height: 400px;
}
.second {
background-color: #17cfe3;
flex-basis: 66%;
height: 200px;
}
.third {
background-color: #fcba03;
flex-basis: 33%;
height: 200px;
}
<div class="container">
<div class="first">a</div>
<div class="second">b</div>
<div class="third">c</div>
</div>
2
Answers
.first
is considered to be on the same "row" as.second
whereas.third
is on a second, unrelated "row".These days, you can use grid, which is both nice and clean:
Try it:
made some flex parameter changes, try out..
feel free to change any values, approach used is flex-column