Hi Gerardo!
It looks like your site does not have an element with id="logo"
. For this reason, the CSS that you shared has no effect.
Is this the logo that you’d like to change? 👇
If yes, then the HTML of this logo is the following:
<img src="https://www.to-bark.com/wp-content/uploads/2018/04/logo-completo-con-rilievo.png" class="jet-logo__img" alt="To-Bark" width="504" height="140">
You could update the CSS to this:
@media only screen and (max-width: 981px) {
img.jet-logo__img {
content: url("http://yourwebsite.com/mobile_logo.png");
}
}
Then, it would work to update your logo.
However, ideally, you could use a <picture>
element to achieve what you want with just HTML. Take a look at this example:
<picture>
<!-- When the screen is narrower than 981px, load small.jpg -->
<source srcset="https://projectdmc.org/path/to/small.jpg" media="(max-width: 981px)">
<!-- Default image for screens wider than 981px -->
<img src="https://projectdmc.org/support/topic/mobile-logo-not-working-with-custom-css/path/to/large.jpg" alt="Descriptive text">
</picture>
- HTML Structure: Instead of using a regular
<img>
tag, use the<picture>
element. This element works with one or more<source>
elements and an<img>
element as a fallback. - CSS Media Queries: You define different
srcset
attributes for each<source>
element, which are then activated based on media queries.
Thank you! now I managed to replace the image but if I attach an already resized logo it is loaded in full in the sense that it occupies the same space, result: I find myself the same size but with the logo obviously blurred because I am not viewing it with the original dimensions.
The “small” logo from your site ) seems to have an intrinsic width of 150px
.
You could try adding an explicit width to your logo in CSS. For example:
@media only screen and (max-width: 981px) {
img.jet-logo__img {
content: url("http://yourwebsite.com/mobile_logo.png");
width: 150px;
}
}
It worked, thanks for the help, I appreciate it!