Container query not working
Hello, my container query on .gridContainer is not working at all. If i change it to @media it works fine and dandy but the moment i try to use @container it just breaks and doesnt create me a 4 column layout on desktop as it should :
3 Replies
you haven't specified what you want to apply the
grid-template-columns
to. you'd need to do something like this. Container queries are like media queries where you have to do this.
Even then, that won't work because you can't apply styles to the parent container with the container query. That's why @media
works and this doesn't. It has to be a child of the parent that is the container. I'd wrap .gridContainer
in a div and make that div the container, then apply the styles to .gridContainer
like in my example since it would then be the child.Thanks dude, I was pulling my hair here, you saved me a lot of time
no worries man, glad you sorted it.