I have a problem with flex.
I have a wrapper where a minimum of 1 and a maximum of 9 squares can be displayed. Squares can have several sizes, depending on the number of squares in the grid. I have all the necessary work cases, except for one, as can be seen in this picture:
My styles:
.grid { display: flex; flex-wrap: wrap; justify-content: flex-start; align-content: space-between; width: 300px; height: 300px; position: relative; }
Plus Images have a size based on their total number and their position in the list.
So the problem is when I have 1 large square (occupies the position of 4 small squares) and 5 small squares around it on the right and bottom.
Big, first, how it should be.
Next to it (upper right corner) is the second, which is also correct.
The third is in the lower left corner, and it should be in the second row and in the right corner. Because of this, everyone else is in the wrong position, so the latter overflows.
I tried many combinations of values ββfor justify-content
, align-content
, align-items
and align-self
, but nothing worked.
I will return to a ton of classes and deliver an absolute solution if there is no flexible solution for this. But I do not like it. It's too many styles and it doesn't look very good.
Any advice is appreciated.
Laker source share