【发布时间】:2015-08-07 04:13:20
【问题描述】:
编辑添加,所以没有其他人将此作为答案发布:我的代码中已经有一个视口标签。
我已经阅读了这里对类似问题的许多回复,我确信我的问题可能在于我的查询声明的顺序中的某个地方,但我终其一生都无法弄清楚在哪里。
我有两个 div,一个应该在宽布局中显示,一个应该在窄布局中显示。
<!-- for small layouts -->
<div class="container-fluid slogan text-center" id="home-slogan-container-small">
small
</div>
<!-- for 800 px and wider -->
<div class="container-fluid slogan text-center" id="home-slogan-container-large">
large
</div>
(这些非常精简;实际内容在 div 内具有不同的布局。)
我遇到的问题是,无论我将浏览器缩放到什么大小(在 FF 中使用 ctrl-shift-m 进行测试以获得移动视图,并在 Chrome 中使用开发工具中的移动视图按钮进行测试),小布局显示。
这是我的 CSS:
#home-slogan-container-small {
padding-top: 15px;
text-align: center !important;
display: none;
}
#home-slogan-container-large {
padding-top: 15px;
text-align: center !important;
display: none;
}
@media only screen and (max-width: 1500px) {
#home-slogan-container-small { display: none !important;}
#home-slogan-container-large { display: block !important;}
}
@media only screen and (max-width: 1200px) {
#home-slogan-container-small { display: none !important;}
#home-slogan-container-large { display: block !important;}
}
@media only screen and (max-width: 960px) {
#home-slogan-container-small { display: none !important;}
#home-slogan-container-large { display: block !important;}
}
@media only screen and (max-width: 800px) {
#home-slogan-container-small { display: block !important;}
#home-slogan-container-large { display: none !important;}
}
@media only screen and (max-width: 799px) {
#home-slogan-container-small { display: block !important;}
#home-slogan-container-large { display: none !important;}
}
@media only screen and (max-width: 420px) {
#home-slogan-container-small { display: block !important;}
#home-slogan-container-large { display: none !important;}
}
@media only screen and (min-width: 300px) {
#home-slogan-container-small { display: block !important;}
#home-slogan-container-large { display: none !important;}
}
我是一名 PHP/mySQL 开发人员,我有一个引导站点。 CSS 不是我的强项。任何解释将不胜感激。
【问题讨论】:
标签: php html css media-queries