css媒体查询问题?

@media (min-width:1200px) and (max-width:1366px) {}
@media (min-width:1367px) and (max-width:1601px) {}

这么写对吗
针对电脑不同分辨率?

阅读 2.5k
2 个回答

对的 你复制看下就知道了
<!DOCTYPE html>
<html>
<head>

<title></title>

</head>
<body>
<style type="text/css">

@media (min-width:1200px) and (max-width:1366px) {
    body{
        background: blue;
    }
}
@media (min-width:1367px) and (max-width:1601px) {
    body{
        background: red;
    }
}

</style>
</body>
</html>

@media (min-width:1200px) and (max-width:1366px) {}
/* 描述的是 [1200,1366] 范围内的样式 */
@media (min-width:1367px) and (max-width:1601px) {}
/* 描述的是 [1367,1601] 范围内的样式 */

但是超过 1601px 的范围内容将于小于 1200px 的小屏幕样式一致,这应该不是你想要的结果
所有需要做下更改

@media (min-width:1200px) and (max-width:1366px) {}
/* 描述的是 [1200,1366] 范围内的样式 */
@media (min-width:1367px) and (max-width:1601px) {}
/* 描述的是 [1367,1601] 范围内的样式 */
@media (min-width:1602px) {}
/* 描述的是 超过1602 范围内的样式 */
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题