I need to make blocks in three columns of type 
Blocks can stretch in width, but each has a fixed height. The problem begins when I try to make them adaptive. To achieve at least an exemplary behavior, I used flex, bootstrap, I tried it myself, but in the end I stopped at bootstrap. If the screen is too wide, then there should be three columns, if normal, then two, and if small, then one. With the first and last option, everything is extremely simple. But what to do with the second?
I will give an example of what I have:
But in two does not come out, there is an empty space in the red block. 
I understand that this is because of the height of the first line and it’s impossible to do something about it, but perhaps there is some other approach to writing this in this situation.
I have an idea to leave everything as it is, only after there are two columns, to hide the third column and use js to distribute its elements among the existing two. Only for some reason it seems to me that this is a huge crutch and there should be an option that I missed.
Any ideas?

