I am trying to calculate an algorithm:
1) get the width of the container containing the blocks (the container must be relative so that it expands when the window is resized). To get the width, use .widthor.outerWidth
2) divide the width of the container by the width of the block, place it. Now you know how many blocks fit on one line.
3) To calculate the height, it can be difficult, because you can have a heading or navigation, etc., which reduces the vertical space down. So do this:
3.1) Get the height of the window $(window).height();
3.2) Get the top container offset $('#container').offset().top
3.3) -
( : .., reserverd)
4) ( /) . , .
5) . . , , , .
6) $('.block') $('.block').each(function(index) { ... }); , . , , !
7) $(window).resize(function() { })