I have a row with 6 items. Depending on the width it will break the items into new rows.
The problem is that this can happend (asterix is an item):
*****
*
When I resize the screen I want it to adapt like below:
******
***
***
**
**
**
*
*
*
*
*
*
I know I can use media queries for this but I hope there is some other solution. Is there?
main {
background: #eee;
max-width: 600px;
}
section {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(100px, auto));
grid-gap: 1rem;
}
div {
background: #ddd;
}
<main>
<section>
<div>Item</div>
<div>Item</div>
<div>Item</div>
<div>Item</div>
<div>Item</div>
<div>Item</div>
</section>
</main>