I am creating a website, and I want the contents of some page (which is text content) to be displayed as two columns. I am using flexbox as a container of the content where the width of each part of the content is 50%
. The problem is shown in the image below:
I want the 3s div to take up the space left below the 2s div instead of remaining empty and ruining the look of the page.
Here is a simple code that demonstrate the case:
#container {
display: flex;
flex-wrap: wrap;
}
.d {
box-sizing: border-box;
font-size: 24px;
width: 50%;
padding: 25px;
text-align: justify;
}
<div id="container">
<div class="d" id="d1">
1111 1111 111 1111 1111 111 111 1111 1111 111 1111 1111 111 111 1111 1111 111 1111 1111 111 111 1111 1111 111 1111 1111 111 111 1111 1111 111 1111 1111 111 111 1111 1111 111 1111 1111 111 111 1111 1111 111 1111 1111 111 111 1111 1111 111 1111 1111 111
111 1111 1111 111 1111 1111 111 111 1111 1111 111 1111 1111 111 111 1111 1111 111 1111 1111 111 111 1111 1111 111 1111 1111 111 111 1111 1111 111 1111 1111 111 111 1111 1111 111 1111 1111 111 111 1111 1111 111 1111 1111 111 111 1111 1111 111 1111
1111 111 111 1111 1111 111 1111 1111 111 111 1111 1111 111 1111 1111 111 111 1111 1111 111 1111 1111 111 111
</div>
<div class="d" id="d2">
222 22222 222 222 2 2 22 2 22 222 22222 222 222 2 2 22 2 22 222 22222 222 222 2 2 22 2 22 222 22222 222 222 2 2 22 2 22 222 22222 222 222 2 2 22 2 22 222 22222 222 222 2 2 22 2 22 222 22222 222 222 2 2 22 2 22
</div>
<div class="d" id="d3">
3333 33 3 333 33 333 3333 333 3333 33 3 333 33 333 3333 333 3333 33 3 333 33 333 3333 333 3333 33 3 333 33 333 3333 333 3333 33 3 333 33 333 3333 333
</div>
<div class="d" id="d4">
444 4 4 4 4 4444 4444 4444 44 444 4 4 4 4 4444 4444 4444 44 444 4 4 4 4 4444 4444 4444 44 444 4 4 4 4 4444 4444 4444 44 444 4 4 4 4 4444 4444 4444 44
</div>
</div>
and here is a CodePen link if you prefer: link