Forum Moderators: martinibuster

Message Too Old, No Replies

Adsense in divs that don't display on some screen sizes

         

IanTurner

8:03 am on May 18, 2017 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



I'm looking to go fully responsive with my design layout (rather than responsive with server side assist)

This is causing a problem with my right floated ads as they are not shown on mobile devices. Is it okay to have these in a div that doesn't display on mobile? Or is there another solution to allow these ads to just display on desktop.

LuckyD

10:00 am on May 18, 2017 (gmt 0)

10+ Year Member Top Contributors Of The Month



If you're on wordpress I can highly recommend the plugin called AmpedSense. Does exactly that

Peter_S

10:39 am on May 18, 2017 (gmt 0)

5+ Year Member Top Contributors Of The Month



In javascript , I test the screen width to select which code to insert (or not).

IanTurner

11:51 am on May 18, 2017 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



JavaScript will work but isn't perfect when display width changes - such as the portrait to landscape change on most mobiles/tablets

denisl

2:30 pm on May 18, 2017 (gmt 0)

10+ Year Member Top Contributors Of The Month



If you are using responsive ads, you can set them to not show on certain screen sizes with a media query.

jbnz

6:11 pm on May 18, 2017 (gmt 0)

10+ Year Member Top Contributors Of The Month



Yep, as denisl says, CSS media queries are the way to go .... recommended by Google too, here's the Google support page on media queries and adsense

[support.google.com ]

(Hope the link is OK, mods?)

LuckyD

5:02 pm on May 20, 2017 (gmt 0)

10+ Year Member Top Contributors Of The Month



jbnz has the solution, just tried on my responsive ads

NickMNS

1:57 am on Jun 7, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



One warning, be sure that you media query targets the <ins> tag and not the parent div. If you simply set the parent div to display:none, then the ad may still be requested but not shown. The class must be attributed to the <ins> tag in the ad code as shown on the Google support page linked by jbnz.