How to organize a uniform filling of the parent divas diva?

There is a parent div block. Within it are a rectangular content blocks. It is unknown how many of them will, because they are added in the admin category. I wish they nicely filled out the parent Div.

Rummaged in the algorithm of masonry, but it doesn't quite fit. It is necessary to set the block size - double height or double width. And that JS himself has distributed them evenly - this will not work.
Here, for example, 4 pieces. In this case, it would be nice, if only it was two rows of two blocks.
If there are five of them, two on top, one in center, two at the bottom.

Well, or such an algorithm to the size picked up - like when you add pictures in VK. There's also all of the pictures occupy a rectangular space. But it's not masonry
June 26th 19 at 14:07
1 answer
June 26th 19 at 14:09
Solution
Flexbox? CSS Grid?
it would be no flake. While the CSS Grid isn't going to help? it should be the same in several rows several columns to place and is not known in advance how many there will be elements. - Miracl commented on June 26th 19 at 14:12
: well, who forbids with JS CSS Grid forming. And what about "it would be no flake"... If the flake is the solution, why not use them? - blake_Eichma commented on June 26th 19 at 14:15
: using js to generate css grid is a good solution. and Flex is compatible with all browsers. With modern working, of course. But in the TOR stipulates that the work must be with earlier versions unfortunately. - Miracl commented on June 26th 19 at 14:18
: Polyfill not? - blake_Eichma commented on June 26th 19 at 14:21
: you can probably ) I'll have to study this library. has not been used before because it is mainly a backend deal - Miracl commented on June 26th 19 at 14:24
under the polyfill implied the imitation of something with the other features. In JS for example - blake_Eichma commented on June 26th 19 at 14:27
Yes. I understand. for compatibility with older versions of the browser. I read already ) thanks going to test it. - Miracl commented on June 26th 19 at 14:30
: if you are satisfied, mark me solution - blake_Eichma commented on June 26th 19 at 14:33
: did. why do you need rankings? - Miracl commented on June 26th 19 at 14:36
: CDA to raise :DD - blake_Eichma commented on June 26th 19 at 14:39

Find more questions by tags CSSHTMLJavaScript