Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Media query works in devtools, but not on mobile device

I am trying to use a media query like this:

.search-results {
    width: 1000px;
    padding-top: 100px;
    margin: 0 auto;

    @media (max-width: 900px) {
       width: 100vw;
       padding-top: 40px;
    }
}

to make it look good in mobile, it works in chrome devtools, but the width stays the same in mobile. Here are the screenshots:
mobile
desktop

The <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"/> tag is included in the <head>

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The @media rule should be outside of the class selector.

.search-results {
    width: 1000px;
    padding-top: 100px;
    margin: 0 auto;
}
@media (max-width: 900px) {
    .search-results {
       width: 100vw;
       padding-top: 40px;
    }
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading