Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to left align responsive adsense image ads?

I am using responsive adsense ads. By default, the text ads are nicely left aligned but the image ads have a very wide left margin for some reason. I can't get rid of it, even if I take the most simple page, i.e. a page with only an ad on it:

<!DOCTYPE html>
<html>
<head>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
</head>
<body>
<!-- Responsive Ad -->
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="xxx"
     data-ad-slot="xxx"
     data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</body>
</html>

Textual ads are left aligned, e.g.:

enter image description here

but image ads contain some wide left margin, e.g.:

enter image description here

My question is how can I make sure that image ads are left-aligned?

like image 410
Paul Jansen Avatar asked Aug 23 '15 22:08

Paul Jansen


3 Answers

Try putting it in a container and give the container a max-width and maybe text-align: left.

<!DOCTYPE html>
<html>
<head>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
</head>
<body>
<!-- Responsive Ad -->
<div id="ad" style="width: 100%; max-width: 600px; text-align: left;">
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="xxx"
     data-ad-slot="xxx"
     data-ad-format="auto"></ins>
</div>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</body>
</html>

Hard to solve without having a test page that you can try playing with.

like image 129
Jacob Avatar answered Oct 04 '22 00:10

Jacob


Try this - put your adsense code in a div, and style the div like this:

<div style="margin: 5px !important; float: left !important;"> 
    --Put your AdSense ad code here --
</div>
like image 36
Mingle Li Avatar answered Oct 04 '22 00:10

Mingle Li


I have seen your webpage. And I have applied the following style

Try the following css in your file

.container {
padding-left:0px;
margin-left:10px;
}

Let me know if it is helpful

like image 28
Rajesh kannan Avatar answered Oct 04 '22 00:10

Rajesh kannan