CSS 中的媒体查询未按预期工作

Media Query in CSS Not working as expected

我需要根据设备宽度在我的网站上显示两个不同的徽标。 如果设备的屏幕尺寸小于或等于300px,我需要显示小标志。

站点:http://www.geekdashboard.com/

Logo.png -> http://www.geekdashboard.com/wp-content/themes/geekdashboard/images/logo.png

徽标-small.png -> http://www.geekdashboard.com/wp-content/themes/geekdashboard/images/logo-small.png

CSS:

.header-image .site-title > a {
    background: url(images/logo.png) no-repeat left;
    float: left;
    min-height: 90px;
    width: 425px;
}

和CSS对于小宽度设备如下

  @media only screen and (max-width: 320px) {

.header-image .site-title > a {
    background: url(images/logo-small.png) no-repeat left!important;
    width: 300px!important;
}

}

这段代码对我来说没有按预期工作。即使在屏幕尺寸小于 300px 的设备上,我仍然可以看到 logo.png 提前致谢

试试这个?

@media (max-width: 320px) {
    .header-image .site-title > a {
     background: url(images/logo-small.png) no-repeat left !important;
     width: 300px !important;
     }
}
@media (min-width: 321px) and (max-width: 480px) {

    .header-image .site-title > a {
    background: url(images/logo.png) no-repeat left;
    float: left;
    min-height: 90px;
    width: 425px;
    }
}
Specifying the media type should work fine.

@media only screen and (max-width: 320px) {
    .header-image .site-title > a {
     background: url(images/logo-small.png) no-repeat left !important;
     width: 300px !important;
     }
}

@media only screen and (min-width: 321px) {
    .header-image .site-title > a {
    background: url(images/logo.png) no-repeat left;
    float: left;
    min-height: 90px;
    width: 425px;
    }
}

不确定,但您的网站似乎启用了缓存,并且在您的 CSS - http://imgur.com/shhDjYa

中并未将 "logo.png" 更改为 "logo-small.png"

也许可以尝试清除缓存,这会对您有所帮助!