简体   繁体   中英

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: 在此处输入图片说明

But, When i test it on real mobile device, it is not centered: 在此处输入图片说明

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;

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM