【问题标题】:specific media query not overriding?特定的媒体查询没有覆盖?
【发布时间】:2017-07-25 20:08:20
【问题描述】:

所以我想在 750px 和 500px 处更改一个元素:

.footer-logo img {
 content:url(...);
 }

然后:

@media only screen and (max-width: 700px) {
.footer-logo img{
margin-top: -58px !important;
padding:64px;
}
}



@media only screen and (max-width: 500px) {
.footer-logo img {
width: 80vw !important;
max-width:none !important;
margin-top:-10px !important;
}

发生了 500px 的变化,但在 700px 测试时没有发生变化。我知道我不应该使用 !important 这么多,但没有它就不会发生样式...任何帮助表示赞赏

【问题讨论】:

  • 您可以尝试添加 500px 更改媒体后添加 700px 媒体查询。
  • 你能提供代码 sn-p 吗?
  • 我把答案请检查它。我认为它是工作。

标签: css resize media-queries


【解决方案1】:

你可以试试这个。请检查 div 颜色变化 根据媒体查询
HTML

<div class="footer-logo">
<img src="http://dummyimage.com/100x50/000/fff&text=Throbble!">
</div>

CSS

@media only screen and (max-width: 700px) {
.footer-logo > img{
margin-top: -58px !important;
padding:64px;
}

.footer-logo {
  background-color:yellow;
}
}

@media only screen and (max-width: 500px) {
.footer-logo > img {
width: 80px !important;
max-width:none !important;
margin-top:-10px !important;

}
.footer-logo {
  background-color:red;
}

}

【讨论】:

  • 感谢这帮助我确定我的媒体查询大小应该是 700 像素和 400 像素!
猜你喜欢
  • 1970-01-01
  • 2014-09-27
  • 2012-07-10
  • 1970-01-01
  • 2016-02-10
  • 2014-05-09
  • 2020-12-23
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多