Hello! Tell me please! There are 3 albums-menu ul and on each (as the cover) always a different number of images from 1 to 4
If one image is in a block then width:100% i.e. totally 400x400
If two then 50% - it is necessary that the pictures automatically go under 400x400
If three then 30% - in general, the block size is fixed and the pictures themselves should fit and not leave empty places.
How to compose js which will count the count of li in the class and depending on the count will work the desired css width:% and the images will completely fill the ul block
<style> ul{ width:400px; height:400px; } </style> <body> <ul class="block"> <li class="img"></li> </ul> <ul class="block"> <li class="img"></li> <li class="img"></li> </ul> <ul class="block"> <li class="img"></li> <li class="img"></li> <li class="img"></li> </ul> </body>