14

I have a HTML like:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Code: NewYork</title>
    <link rel="stylesheet" href="test.css" />
</head>
<body data-ng-app="us">
    <input type="text" />
</body>
</html>

and my CSS is:

input {
  background-color: red;
}
/* ---- Desktop */
@media only screen and (min-width: 1000px) and (max-width: 1200px) {
    input {
        background-color: green;
    } 
}

now the CSS applies when the window is at 909px width. Obviously not a scrollbar problem. I am getting nuts with this simple problem. I tested it with Chrome and IE10 both the same.

Can anybody please help what I am doing wrong here?

3 Answers 3

19

I used this HTML:

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Code: NewYork</title>
</head>
<body data-ng-app="us">
    <input type="text" />
</body>
</html>

With a simpler media query declaration like this one:

@media (min-width: 1000px) and (max-width: 1200px) {

 input {
        background-color: green;
    } 

}

It's working great here: http://jsbin.com/ubehoy/1

Debugging with Firefox Responsive Design View and dragging the resizer, it changes the input background color correctly when the width limits are reached.

Tried with Chrome 26.0.1410.64 m/IE 10 and it's working great too.

Sign up to request clarification or add additional context in comments.

10 Comments

Damn i was stupid. that tab was at zoom level spent hours on this -_- i should work so late... thanks!
big upvote for @user1974505 I had the same stupid zoom at 110%. As soon as I read it I did a /facepalm and reset to default... works like a charm!
I had the exact same problem. And yes, the magnifier was on! Didn't know that would affect the reported pixel width of the page.
Magnifier fail for me too... :(
Just have to check in and say that zooming was really wrecking me and I'm sure I wouldn't have seen this on my own, thanks!
|
8

I have had this happen to me from time to time. Make sure your tab is not zoomed in (⌘0)

Comments

1
@media (min-width: 1000px) and (max-width: 1200px) {

 input {
        background-color: green;
    } 

}

This works, but make sure you check the zooming. (I got this answer from the comments, as it seems this is the big catch around here.. I fell for it too)

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.