Reputation: 973
I need to show two different logos on my site depending on the device width. If the screen size of device is 300px or less than it, i need to show small logo.
Site: http://www.geekdashboard.com/
Logo.png -> http://www.geekdashboard.com/wp-content/themes/geekdashboard/images/logo.png
logo-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;
}
and CSS for small width devices as follows
@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;
}
}
This code is not working as expected for me. I can still see the logo.png even on devices with screen size less than 300px Thanks in advance
Upvotes: 0
Views: 1687
Reputation: 359
Not sure but seems cache is enabled on your site and it didn't changed "logo.png" to "logo-small.png" in your CSS - https://i.sstatic.net/ujoUP.jpg
Probably try clearing your cache, it would help you!
Upvotes: 1
Reputation: 111
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;
}
}
Upvotes: 1
Reputation: 294
Try this?
@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;
}
}
Upvotes: 0