How to make Taku the net?

There is an example of how images should be located every block.
there will be 3 different galleries.

Work have added 1 picture look like the first block.
Add 2 images look turns out as 2 units.
Added 3 images look turns out like 3 blocks.
etc.

Here is an example of how it should be.
https://docs.google.com/document/d/1P9CSG3XRu9RXph...
March 23rd 20 at 19:13
2 answers
March 23rd 20 at 19:15
Solution
March 23rd 20 at 19:17
Js to write a function, which, depending on the number of incoming files builds the required mesh (with the right number of elements), and then using CSS everything is made and everything. Or similar option - js looks at the number of objects and adds the class modifier in the parent container.
Can you tell how organizovati counting objects and add class ? - Mateo.Reichert92 commented on March 23rd 20 at 19:20
When adding a class to the parent, the rough logic is:
  1. Get all objects set up in an array (arr)
  2. Find out the length of the array (arr.length)
  3. The item you add a class depending on the length (element.classList.add('name-class') - in its simplest form, you can add the arr.length as a class with any prefix)
- Dusty.Pacocha commented on March 23rd 20 at 19:23
@Dusty.Pacocha,
$(document).ready(function () {
 $(".gal").each(function() {
 var len = $('div.gallery__item', this).length;
 if (len < 2){
$(".gal").addClass('active')
}
else{

}
});
});

So ? - Mateo.Reichert92 commented on March 23rd 20 at 19:26
Yeah, kind of - Dusty.Pacocha commented on March 23rd 20 at 19:29
But for some reason it's added to all blocks, not only where is the number of blocks. - Mateo.Reichert92 commented on March 23rd 20 at 19:32
And you can look at the layout code? - Dusty.Pacocha commented on March 23rd 20 at 19:35

Find more questions by tags jQueryCSS