Josh
Josh

Reputation: 121

How To Center Adsense Code in Mobile Device

My code:

<div style="style="display:block; float: left; margin: 0px 50px 0px px;>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Paragraph Ad 3rd - Responsive -->
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="ca-pub-xxxxx"
     data-ad-slot="xxxxx"
     data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>   
</div>

Google Adsense is perfectly centered in desktop, even when i resize the device: enter image description here

But, When i test it on real mobile device, it is not centered: enter image description here

Upvotes: 0

Views: 1055

Answers (2)

Ronav
Ronav

Reputation: 26

Try this,

<div align="center" style="display:block; float: left; margin: 0px 50px 0px px;">

if that does not work then try this in the style attribute

text-align: center;

Upvotes: 1

Ronav
Ronav

Reputation: 26

you can put center tags around your Adsense code. Something like this:

<center>
<div style="style="display:block; float: left; margin: 0px 50px 0px px;>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Paragraph Ad 3rd - Responsive -->
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="ca-pub-xxxxx"
     data-ad-slot="xxxxx"
     data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>   
</div>
</center>

Hope this helps man. Cheers.

Upvotes: 0

Related Questions