How can I hide an ad in the mobile version of Dawn?

Can I hide this advertisement below in mobile version? Desktop is fine but on mobile it looks terrible.

Thank you all!

DESKTOP

MOBILE

Hi @iwonder ;

You need to use the media query. I cannot give you the exact code since I do not have your website, but check the code below for reference.

@media only screen and (max-width: 481px) {
.advertisement-section {
display: none !important
}
}

Thank you @made4Uo , it’s a banner from Amazon, can I still use this type of media query?

Yes, but you have to call the banner, change the “advertisement-section” to the class or id associated to the element.

I appreciate your help. Thank you.

<img id="amznBanners_assoc_banner_placement_default_${slotNum}_img"

I’ve tried this:

@media only screen and (max-width: 481px) { .“tried on both ids above” { display: none !important } }

And this one:

@media screen and (min-device-width: 320px) and (max-device-width: 749px) { .“tried on both ids above” { display: none; } }

But still look the same.

Thank you for your time.

Forgot to mention… I am adding this code in base.css

Does this code have a class? This ID is dynamic

This is all it has.

Hi @iwonder ,

Try this code.

  1. Go to Admin page > Online store > themes > Actions > Edit code
  2. Open the base.css under the Asset folder then add the code below.
@media only screen and (max-width: 481px) {
div[id^="amznBanners_assoc_banner_placement_default"][id$="_div"]  {
display: none !important
}
}

Hi @iwonder ,

We can’t really change the CSS of the elements that has been rendered by an iframe but this is still doable. The code will adjust to the size of the screen instead. I didn’t think that you really want it to be hidden on mobile screen. Please follow the instructions below.

  1. Go to Admin page > Online store > themes > Actions > Edit code
  2. Open the base.css under the Asset folder then add the code below.
#shopify-section-template--16111507439847__1654786710591ef634 iframe {
    width: 100%;
    max-width: 728px;
}

Oh I see, so the banner stays there and the screen doesn’t scroll to the length of the banner?

@iwonder Hard to tell what I am missing. This is what I see in my side.

on mobile version it shows the badge like this. It’s a strange one this isn’t it. I guess that’s why some people stick with adsense etc. Maybe I’ll see if I can get a mobile size version instead.

Hmmm. Weird on why I am not seeing the image. I can adjust the aspect-ratio of the iframe but I just need to see the image.

Does it have something to do with javascript?

Hi @iwonder ,

I am trying to do this blindly, but change the previous code to this. Hopefully it will fix the issue.

#shopify-section-template--16111507439847__1654786710591ef634 iframe {
    width: 100%;
    max-width: 728px;
    aspect-ratio: 16/2;
    padding: 0 2rem;
    height: auto;
}

Can you try to open your website in incognito browser? For some reason the iframe is not rendering

Looking better, I think we are getting there. :grinning_face_with_smiling_eyes:

Perhaps because its an iframe the image doesn’t change size?

Yes. It would not. Try to play the aspect-ratio (see in bold). You can try “20/2”. Sorry, I am just seeing blank ad.

#shopify-section-template–16111507439847__1654786710591ef634 iframe { width: 100%; max-width: 728px;

aspect-ratio: 16/2;

padding: 0 2rem;

height: auto;

}