Grid areas reassign values instead of making it switch places
I have following CSS code:
This code has my markup for desired two columns three rows grid, works out just fine. However, in my media query I want them to switch places and become one column grid, like this:
But instead of switching places, it just reassigns the values. The one that supposed to be
brand
becomes egg
and so on.
What is wrong with my layout? I watched Kevin's tutorial on grid and picked it up there, but apparently I'm doing something wrong.9 Replies
did you assigned those names to the children of the grid ?
I didn't. Do I have to? I don't think Kevin did this in his grid video.
how else the browser is suppose to know what to place where
he definitely did
if you use the areas you need to specify which area is which
Huh, I thought the initial markup before the media query actually provides browser with information.
Do I have to do that with
grid-area
property for each of the children?yes
if you want to reorder them
I've seen how Kevin does it in this part of the video (timecode attached):
https://youtu.be/rg7Fvvl3taU?t=1778
He firstly initialized his values in
grid-template-area
, and then just reordered them in a media query, so that's why I thought you could do that do. Or perhaps you can't really do that in my case? Or I just wasn't attentive enough.Kevin Powell
YouTube
Learn CSS Grid the easy way
It can be easy to get bogged down in how grid works, with a lot of new properties, values, and even units! So let's try and simplify things as much as possible, because to get started, you don't need to know everything about how Grid works.
🔗 Links
✅ The GitHub repo: https://github.com/kevin-powell/learn-grid-the-easy-way
✅ More videos on gr...
same video https://youtu.be/rg7Fvvl3taU?t=1993
Kevin Powell
YouTube
Learn CSS Grid the easy way
It can be easy to get bogged down in how grid works, with a lot of new properties, values, and even units! So let's try and simplify things as much as possible, because to get started, you don't need to know everything about how Grid works.
🔗 Links
✅ The GitHub repo: https://github.com/kevin-powell/learn-grid-the-easy-way
✅ More videos on gr...
Thanks for pointing that out! I wasn't attentive enough after all.
Thank you for all the tips!
Good luck