我在移动设备上没有使用媒体查询时遇到问题。这在浏览器上可以正常工作,但在移动设备上却不行(实际上 Lumia 800 和 iPhone 手机之间的渲染似乎不同)。我已经浏览了大多数有关此问题的帖子,并且在大多数情况下人们忽略了元标记,但我已经将它设置在文档的头部;
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
这是我的移动 CSS 文件:
/* ===== == = === 20em (320px) === = == ===== */
@media screen and (min-width : 20em) {
.slidercontainer {
display:none;
}
}
@media only screen and (min-width : 30em) {
}
/* ===== == = === 37.5em (600px) === = == ===== */
@media only screen and (min-width: 37.5em) {
}
/* ===== == = === 48em (768px) === = == ===== */
@media only screen and (min-width : 48em) {
.slidercontainer {
display:inherit;
}
}
/* ===== == = === 56.25em (900px) === = == ===== */
@media only screen and (min-width : 56.25em) {
}
/* ===== == = === 68.75em (1100px) === = == ===== */
@media only screen and (min-width : 68.75em) {
.container {
width:1200px;
}
}
/* ===== == = === 81.25em (1300px) === = == ===== */
@media only screen and (min-width : 81.25em) {
}
在头部区域,我还包含 2 个样式表,一个带有常规 CSS 的默认样式表和带有 .. 的移动样式表 :)
<link href="css/default.css" rel="stylesheet" type="text/css" />
<link href="css/mobile.css" rel="stylesheet" type="text/css" media="all"/>