XF 2.2 Alignment problem with Google Adsense in narrow format

Bonsai Coder

Active member
I have a tricky little problem that I am certain someone will have an easy fix for, but I can't figure it out.

I have my forum set up for narrow, medium and wide screen formats. All my Xenforo content aligns perfectly for all three widths. However I have a problem with Google Adsense ads - in the narrow and ONLY the narrow format. For some reason that I can't figure out, there is an additional margin that is added to the left of the ad that causes the ad to not display properly. In other words, the ad should be left aligned, and should fit perfectly, but instead the additional margin causes the ad to overflow the screen when you view the site on cell phones.

You can see the problem in this image. Note that even though this is the front page of the site, the format problem is consistent on forum pages, and ads that appear above and below the forum content.

Any help?

formating-help.webp
 
I am simply using the "Advertising" menu under "Setup" to insert the following code from Google:

Code:
<center>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- BNUT Responsive Ad Top -->
<ins class="adsbygoogle"
     style="display:block;min-width:400px;max-width:1200px;width:100%;height:100px"
     data-full-width-responsive="true"
     data-ad-client="ca-pub-______________"
     data-ad-slot="____________"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>

I have spent time playing around with PAGE formatting - for the page width breaks for responsive formatting for screens with different widths. However nothing I do removes that margin in narrow formatting.

I have also tried removed the <center> from the code above... or even left aligning... but nothing seems to work seamlessly.
 
Last edited:
Back
Top Bottom