https://idea-hack.com/blog/35681/
How to fit Google Adsense responsive ads to the size of the parent element

How to fit Google Adsense responsive ads to the size of the parent element

The Google Adsense responsive ad unit automatically spreads across the screen when viewed on a smartphone.
I will show you how to prevent this.

Use data-full-width-responsive attribute

Please look for data-full-width-responsive in script tag.

code
data-full-width-responsive="true"

This is true by default.
This setting is whether to automatically expand and display the full-screen width when viewed on a smartphone.

If this is changed to false, the automatic expansion will be turned off.

And, the responsive ad will be adapted to the width of the parent element.

code
data-full-width-responsive="false"

It is OK if it can be described as the sample below.

javascript
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle"
     style="display:block; text-align:center;"
     data-ad-layout="in-article"
     data-ad-format="fluid"
     data-ad-client="hogehoge"
     data-ad-slot="111111111"
     data-full-width-responsive="false"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>

Summary

This code fix is also acceptable to Google.