#wrapper {
display: flex;
flex-flow: row wrap;
}
#wrapper .one,
#wrapper .three {
flex: 100 0 34%;
}
#wrapper .two,
#wrapper .four {
flex: 1 0 34%;
}
.one::before {
content: "";
float: left;
padding-top: 10%;
}
.three::before {
content: "";
float: left;
padding-top: 30%;
}
/*properties below are just for cosmetics*/
.one {
background: violet;
}
.two {
background: orange;
}
.three {
background: limegreen;
}
.four {
background: dodgerblue;
}
#wrapper {
border: 2px solid gray;
}
.one::before {
border: 2px solid maroon;
}
.three::before {
border: 2px solid navy;
}
<div id='wrapper'>
<div class='one'></div>
<div class='two'></div>
<div class='three'></div>
<div class='four'></div>
</div>
We aim to arrange the flexboxes in two rows, utilizing the flex
and row wrap
properties on the wrapper.
Since the flex-basis
is set at 34%, only two items can fit on a single line. The first and third divs have a higher flex-grow
value, allowing them to occupy most of the remaining space. As a result, the first "column" appears approximately twice as wide as the second "column".
To ensure consistent row heights, we employ a pseudo-element
on the first and third divs. Vertical margins and paddings are determined by the parent's width. By setting the width of the pseudo-element on the first and third divs to be three times larger, the second "row" can be made three times higher compared to the first row.