Reputation: 159
I'm using different media queries to change the number of columns of my CSS grid depending on the browser width. I would like to achieve some kind of animation effect when the grid boxes are changing their position according to this. How can this be achieved using pure CSS?
Parts of the code:
.wrapper {
width: 100%;
display: grid;
grid-gap: 20px;
grid-template-columns: repeat(6, 300px);
grid-template-rows: repeat(10), 300px);
}
@media only screen and (max-width: 1960px) {
.wrapper {
grid-template-columns: repeat(5, 300px);
}
}
@media only screen and (max-width: 1460px) {
.wrapper {
grid-template-columns: repeat(4, 300px);
}
}
Upvotes: 2
Views: 726
Reputation: 115108
This is not possible with CSS.
The number of columns or rows is not animatable. Equally, grid areas are not elements and so cannot be selected with CSS.
Animation type:simple list of length, percentage, or calc, provided the only differences are in the values of the length, percentage, or calc components in the list.
Upvotes: 2