The magic to make it act that way is the two css lines below.
display: grid;
grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr));
Put this on the parent container and this will give you a responsive grid that adapts the columns with the size of the container.
Here is the whole code example to check out.
Top comments (0)