@media

hi all, there is a problem when i'm setting media queries. whenever i do this:
@media screen and (width >= 1024px) { /* changes layout */ }
@media screen and (width >= 1024px) { /* changes layout */ }
it doesn't change the layout at 1024px, instead, it does so at 920px why does it do that?
6 Replies
Myndi
Myndi2y ago
It shouldn't, perhaps there's another media query interfering.
son arg
son argOP2y ago
hmm, yeah, i suppose so yeah does the positioning of the media query code matter? in the css file? if it's above all the code, below all the code, or in the middle of the code?
Rowe2ry
Rowe2ry2y ago
Yes. It still cascades. If you do “mobile first” style sheets you want all the default styles for mobile at the top and then you want to order your media queries for breakpoints as they get larger and large while you move further down the stylesheet.
@media screen and { min-width:640px }

@media screen and { min-width:1080px}
@media screen and { min-width:640px }

@media screen and { min-width:1080px}
etc. If you do a “desktop first” style sheet, it’s the same thing. Big layouts at top and then smaller and smaller “max-width” queries in order from largest to smallest as you move down the stylesheet.
son arg
son argOP2y ago
dang, i tried that, it's still the same issue okay, found out what the problem was, which i find super odd/weird so when i right click on my index.html and then click on "open with live server", the media query at 1024px doesn't work the page shown on the live server doesn't work, however, if i go into my files and open that same index.html file manually, works perfectly fine weird..
Rowe2ry
Rowe2ry2y ago
Bizarre. That almost sounds like maybe your browser cached an old version of the css with the media queries still out of order? Maybe try a hard reload (might have to Google for your specific browser) but I’m chrome for Windows, that’s “ctrl + f5” and on Mac, “cmd + shift + R”
son arg
son argOP2y ago
i'll try that out, thanks
Want results from more Discord servers?
Add your server