0

I'm trying to make my website responsive using a media query, but the styles inside it are not applying on my phone, even though I'm sure the screen width is under 768px.

body {
    background-color: white;
}

@media screen and (max-width: 768px) {
    body {
        background-color: lightblue;
    }
}

It works when I resize my desktop browser, but not when I open the same page on my phone.

Things I’ve tried:

Clearing browser cache

Testing on multiple phones

Making sure the CSS file is properly linked

Is there something I'm missing? Do I need to set a specific viewport in the HTML?

1

1 Answer 1

0

Is the following code written inside the tag?

<head>
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.