微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

css3 – CSS媒体查询最小宽度无法正常工作

我有一个像这样的 HTML
<!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>

我的CSS是:

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

现在,当窗口宽度为909像素时,CSS适用.显然不是滚动条问题.我对这个简单的问题感到困惑.我用Chrome和IE10测试它们都是一样的.

任何人都可以帮助我在这里做错了吗?

解决方法

我用过这个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>

使用像这样的简单媒体查询声明:

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

 input {
        background-color: green;
    } 

}

在这里工作得很好:http://jsbin.com/ubehoy/1

使用Firefox Responsive Design View进行调试并拖动缩放器,它会在达到宽度限制时正确更改输入背景颜色.

尝试使用Chrome 26.0.1410.64 m / IE 10,它的工作也很棒.

原文地址:https://www.jb51.cc/css/215642.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。