I have a css grid that has 30 cells (for 30 pics).
.sub-gallery{
margin-bottom: 10px;
display: grid;
grid-template-columns: repeat(4,1fr);
grid-auto-rows: 75px;
gap: 10px;
grid-template-areas: "pos0 pos1 pos2 pos3"
"pos0 pos1 pos2 pos3"
"pos0 pos1 pos2 pos3"
"pos4 pos4 pos2 pos3"
"pos4 pos4 pos5 pos3"
"pos4 pos4 pos5 pos3"
"pos4 pos4 pos6 pos6"
"pos7 pos7 pos6 pos6"
"pos7 pos7 pos6 pos6"
"pos9 pos9 pos9 pos8"
"pos9 pos9 pos9 pos8"
"pos9 pos9 pos9 pos8"
"pos9 pos9 pos9 pos8"
"pos13 pos12 pos11 pos10"
"pos13 pos12 pos11 pos10"
"pos13 pos12 pos11 pos10"
"pos13 pos12 pos14 pos14"
"pos13 pos15 pos14 pos14"
"pos13 pos15 pos14 pos14"
"pos16 pos16 pos14 pos14"
"pos16 pos16 pos17 pos17"
"pos16 pos16 pos17 pos17"
"pos18 pos19 pos19 pos19"
"pos18 pos19 pos19 pos19"
"pos18 pos19 pos19 pos19"
"pos18 pos19 pos19 pos19"
"pos20 pos21 pos22 pos23"
"pos20 pos21 pos22 pos23"
"pos20 pos21 pos22 pos23"
"pos24 pos24 pos22 pos23"
"pos24 pos24 pos25 pos23"
"pos24 pos24 pos25 pos23"
"pos24 pos24 pos26 pos26"
"pos27 pos27 pos26 pos26"
"pos27 pos27 pos26 pos26"
"pos29 pos29 pos29 pos28"
"pos29 pos29 pos29 pos28"
"pos29 pos29 pos29 pos28"
"pos29 pos29 pos29 pos28"
;
Problem is: when the number of fetched pics is 30, all is good but when there are less than 30 pics, there are empty cells in the bottom part of the grid and so my next DOM element (a button) appears way down after the corresponding empty space. I have looked this up for a few days to no avail. How can I remove that empty/unused part of the grid when returned number of pics is less than 30?