soranoo / next-google-adsense

Add Google AdSense to your Next.js app.
MIT License
13 stars 2 forks source link

Support positioning the ads unit at the center #3

Closed meotimdihia closed 7 months ago

meotimdihia commented 7 months ago

Support positioning the ads unit at the center

https://support.google.com/adsense/answer/9190028?sjid=6740713815294188350-AP

<div align="center">
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1234567890123456" crossorigin="anonymous"></script>
<!-- Homepage Leaderboard -->
<ins class="adsbygoogle"
style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-pub-1234567890123456"
data-ad-slot="1234567890"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
soranoo commented 7 months ago

You may wrap AdUnit with a div, like this

<div align="center">
      <AdUnit
            publisherId="pub-XXXXXXXXXXXXXXXX" 
            slotId="XXXXXXXXXX"
            layout="display"
      />
</div>
meotimdihia commented 7 months ago

I got it.