A
A
Alrksandr2021-06-16 06:35:01
css
Alrksandr, 2021-06-16 06:35:01

How to evenly distribute columns in a grid container?

Hi all! The problem is this, there is a list of thumbs, the number of thumbs is unknown from 0 to infinity, the size of the thumbs ranges from 190px to 320px. This list should look like this 60c96fe0868a3895242112.jpeg
Styles applied look like this
.grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

But this option is not suitable, because if there are not enough thumbs, they are stretched.

You need something like this
.grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(190px, 320px));
}

But the result is not what I expect, the columns do not shrink and do not adjust to the line width
60c9715d0e509875143328.jpeg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey delphinpro, 2021-06-16
@Alrksandr

Use auto-fill

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question