1

I'm using auto-fill for the columns of my grid. But some times the width of the cells is greater than their height.

Is there a way to keep them squared? While the width increases the height also increases.

ul {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    grid-auto-rows: minmax(100px, auto);
    grid-auto-flow: row dense;
    gap: 10px;
    padding: 10px;
}

ul li {
    background: salmon;
}
<ul>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
<ul>

To illustrate my problem:

enter image description here

enter image description here

Hao Wu
  • 17,573
  • 6
  • 28
  • 60

1 Answers1

2

I think, that you have to use just:

grid-template-columns: repeat(auto-fill, 100px);

instead of

grid-template-columns: repeat(auto-fill, minmax(100px, 1fr);

PredikDev
  • 21
  • 2