Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS media query not applying

I'm using this media query in my main css stylesheet and it doesn't seem to be working.

@media only screen and (max-device-width : 768px) {
    .small { display: block; }
    .big { display: none !important;}
}

In the web inspector it doesn't even show up as a rule, however when i look in the sources panel the query is obviously there. So i'm not sure what the problem could be. I am trying to target devices with a width less than 768px.

Here's how i'm linking to the stylesheet, if that matters <link rel="stylesheet" media="screen" type="text/css" href="{site_url}interface/style.css" />

like image 541
Matt Roelle Avatar asked Jun 26 '26 00:06

Matt Roelle


1 Answers

As you are using max-device-width it won't affect in web browsers, You should check on mobile browsers to see its working or not.

Or if you want to check on web browsers, Then use just max-width instead.

See Working Demo

CSS

@media only screen and (max-width : 768px) {
    .small { display: block; }
    .big { display: none;}
}
like image 159
Surjith S M Avatar answered Jun 28 '26 13:06

Surjith S M



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!