Forum Moderators: martinibuster
/* I hide the mobile slots and show the desktop slots */
@media screen and (min-width: 500px) {
div.adsense_responsive_mobile {display:none;}
div.adsense_responsive_desktop {min-width: 300px; min-height: 250px;}
}
/* I hide the desktop slots and show the mobile slots */
@media screen and (max-width: 500px) {
div.adsense_responsive_mobile {min-height: 266px;}
div.adsense_responsive_desktop {display:none;}
} Can the Mediapartners-Google bot read your css files?
If the change is recent, they seem to take some time to digest the changes to provide usable ads
I wish that AdSense had an equivalent URL inspection tool
Are there any errors appearing in browser console (ctrl+shift+I in Chrome or right click and "inspect element")?
P {message: "adsbygoogle.push() error: No slot size for availableWidth=0", name: "TagError", pbr: true, stack: "TagError: adsbygoogle.push() error: No slot size f…esyndication.com/pagead/js/adsbygoogle.js:80:179)"} If this is that case then you will need to add a height to the style of the parent div of the ad unit. In order for the responsiveness to work the script needs to be able to calculate height or width. You can set a min-height as you did in the media query.
No slot size for availableWidth=0
@media screen and (max-width: 500px) {
div.adsense_responsive_mobile {min-height: 266px;}
div.adsense_responsive_desktop {display:none;}
}
[edited by: not2easy at 3:58 pm (utc) on Jan 30, 2021]
[edit reason] readability [/edit]
<ins class="adsbygoogle mobile_ad".... />
@media screen and (max-width: 500px) {
div.adsense_responsive_mobile {min-height: 266px;}
div.adsense_responsive_desktop {display:none;}
mobile_ad {display:block}
desktop_ad {display:none}
}
<style>
@media screen and (min-width: 550px) {
.mobile_ad_slot {display:none}
.desktop_ad_slot {display:block; min-width: 300px; min-height: 250px;}
}
@media screen and (max-width: 550px) {
.mobile_ad_slot {display:block; min-width: 300px; min-height: 266px;}
.desktop_ad_slot {display:none}
}
</style> <h1>Title</h1>
<ins class="adsbygoogle desktop_ad_slot" data-ad-client="ca-pub-1234" data-ad-slot="123" data-ad-format="auto" data-full-width-responsive="true"></ins><script>(adsbygoogle = window.adsbygoogle || []).push({});</script>
<h2>Subtitles</h2>
<ins class="adsbygoogle mobile_ad_slot" data-ad-client="ca-pub-1234" data-ad-slot="123" data-ad-format="auto" data-full-width-responsive="true"></ins><script>(adsbygoogle = window.adsbygoogle || []).push({});</script> P {message: "adsbygoogle.push() error: No slot size for availableWidth=0", name: "TagError", pbr: true, stack: "TagError: adsbygoogle.push() error: No slot size f…esyndication.com/pagead/js/adsbygoogle.js:80:179)"} If you are doing this to show ads in different locations in your layout then there are better ways to achieve this.
<style>
@media screen and (min-width: 550px) {
.mobile_ad_slot {display:none}
.desktop_ad_slot {display:block; min-width: 300px;}
.ad-wrapper {min-height: 250px;}
}
@media screen and (max-width: 550px) {
.mobile_ad_slot {display:block; min-width: 300px; }
.desktop_ad_slot {display:none}
.ad-wrapper {min-height: 266px;}
}
</style>
<h1>Title</h1>
<div class="ad-wrapper">
<ins class="adsbygoogle desktop_ad_slot" data-ad-client="ca-pub-1234" data-ad-slot="123" data-ad-format="auto" data-full-width-responsive="true"></ins><script>(adsbygoogle =
window.adsbygoogle || []).push({});</script>
</div>
<h2>Subtitles</h2>
<div class="ad-wrapper">
<ins class="adsbygoogle mobile_ad_slot" data-ad-client="ca-pub-1234" data-ad-slot="123" data-ad-format="auto" data-full-width-responsive="true"></ins><script>(adsbygoogle =
window.adsbygoogle || []).push({});</script>
</div>
but I want to place the ads in different places.