Media Query Not Working
Hi, I have a custom cursor that I would like to disable for mobile devices. However, the media query display: none that I'm applying dosen't seem to work.
23 Replies
Are you sure you meant to use
min-height
and not min-width
?
is there a different selector for .media that overrides the display setting lower down?
otherwise, share a live example in codepen or something similar, or just a live version of the code hosted somewhereI've tried that too. My page is a horizontal scroll so I don't know if that affects the media query.
https://codepen.io/g0ldl/pen/PormRYG
you've commented out the media query:
are you not using a code editor with syntax highlighting?
also, just as a heads up, I really had issues using the cursor with the delay you introduced. Dampening the cursor's movement removes the direct feedback I need to position it correctly the first try
I commented it out to show that there's the custom cursor. When I uncomment it and go into responsive mode, it doesn't react the way I expected it to.
Thanks for the feedback, I'll fix that right away.
ah, I found it. You should be using max-height rather than min-height
the media query applies up to 420px with max, with min it's above 420
Still doesn't seem to work for me ):
works fine for me
you could probably also do this with pointer: coarse, rather than relying on the screensize: https://caniuse.com/?search=%40media%20pointer
MDN Web Docs
pointer - CSS: Cascading Style Sheets | MDN
The pointer CSS media feature tests whether the user has a pointing device (such as a mouse), and if so, how accurate the primary pointing device is.
Is media qeury based on the body or is it based on the axises.
afaik it's based on the viewport
so no matter how I rotate the page, height will always be straight up
any type of scrolling shouldn't matter
you're not rotating the page when you have horizontal scroll though
I will check that out.
I thought this is what this meant
oh, yeah, that's a rotation. Still shouldn't matter for media queries, they use the viewport and you can't modify the viewport
Thank you that clarifies it, still have to get it to work though.
like I said, this works in my browser
tested in chrome and firefox
I'm running from VScode and just inspecting element in safari, could this be a potential error?
doesn't matter how it's served, and I can't test in safari
I think I got it to work with
Never knew pointer: coarse exists. I'll push it and test it on actual devices.
It's working, thanks Jochem.
glad to help!