css - 如何将媒体查询仅应用于特定宽度范围

标签 css media-queries

如何在 360 像素 - 640 像素之间应用媒体查询。这与我的 (max-width: 320px) 媒体查询重叠。

@media screen and (min-width:360px) and (max-width:640px) and (orientation : landscape)

My webpage where the problem occurs

最佳答案

除了页面中的这个媒体查询之外,您什么都没有。如果要更改 320px 以下的内容,则需要单独声明。您应该声明影响页面宽度以下所有内容的媒体查询。

这是媒体查询如何工作的一个简单示例:http://jsfiddle.net/ra9ry8t4/1/

在 JSFiddle 中测试可能更容易,但这里它也是一个片段:

@media screen and (min-width: 480px) {
  body { 
    background-color: yellow;
  }
}

@media screen and (min-width: 320px) and (max-width:480px) {
  body { 
    background-color: blue;
  }
}

@media screen and (min-width: 320px) and (max-width:480px) and (orientation: landscape) {
  body { 
    background-color: green;
  }
}

@media screen and (max-width: 320px) {
  body { 
    background-color: red;
  }
}
<h1>Media Queries Example</h1>
<p>Increase or decrease the size of of this window to see the background color change</p>

关于css - 如何将媒体查询仅应用于特定宽度范围,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37478263/

相关文章:

css - 添加新行以使链接垂直对齐

jquery - 我的 jQuery "showcase"- 不透明度问题 :)

internet-explorer-8 - Respond.js在本地不起作用-支持IE8中的媒体查询

javascript - 切换两侧按钮 css

CSS 选择器说明 : |= vs ^=

javascript - 根据下拉菜单中的所选元素而变化的文本区域

css - 使用媒体查询调整流动网格每行的图像数量

css - REM 单元不能用于媒体查询吗?如何更新根字体大小?

javascript - Respond.js 不能跨域工作

css - 我可以在没有设备像素比的情况下使用最大设备宽度和设备宽度吗?