CSS Grid: Create Flexible Layouts Using auto-fill

The repeat function comes with a option called auto-fill.

This allows you to automatically insert as many rows or columns of your desired size as possible depending on the size of the container.
You can create flexible layouts when combining auto-fill with minmax.

In the preview, grid-template-columns  in the first grid container is set to
repeat(auto-fill, minmax(60px, 1fr));



first container
1
2
3
4
5


second container
1
2
3
4
5
When the container changes size, this setup keeps inserting 60px columns and stretching them until it can insert another one.
compare between first and second grid by stretching and minimizing the web-page 
If your container can't fit all your items on one row, it will move them down to a new one.
 source

Comments

Popular posts from this blog

ES6 : 5 Prevent Object Mutation

ES6: 1 Explore Differences Between the var and let Keywords

CSS Grid: Reduce Repetition Using the repeat Function