Solved

Adsense Responsive in the center

Posted on 2014-09-11
1
210 Views
Last Modified: 2014-09-11
Hi E's
I use responsive adsense for present ad's in my projects, and usually I use this code:
 <style>
        .adsense_responsivo { width: 300px; height: 250px; }
        @media (min-width: 300px) { .adsense_responsivo { width: 320px; height: 50px; margin:0 auto; } }
        @media (min-width: 600px) { .adsense_responsivo { width: 468px; height: 60px; margin:0 auto; } }
        @media (min-width: 800px) { .adsense_responsivo { width: 120px; height: 600px; margin:0 auto; }}
        </style>

............

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
                    <!-- Teste responsivo -->
                    <ins class="adsbygoogle adsense_responsivo"
                         style="display:inline-block"
                         data-ad-client="ca-pub-7950738589222540"
                         data-ad-slot="1305288410"></ins>
                    <script>
                    (adsbygoogle = window.adsbygoogle || []).push({});
                    </script>

Open in new window

The problem is, the ad's appear in the left, and I want to put them always in the center.
I try to change this: margin:0 auto; to margin:auto auto; and not work.
What I have to do for present ad's in the center, or the same margin in left and right (responsive).

The best regards, JC
0
Comment
Question by:Pedro Chagas
1 Comment
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 500 total points
ID: 40317059
Margins are set within the parent element of the ads, so you nee to make sure that the parent ogf the ads is width:100%. If the code for the parent is written by the Google script, then you might not be able to modify the width property.

Cd&
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When writing CSS, there are a few simple rules that will make your life easier.    1. Using ‘* {box-sizing:border-box;}’. Using this will wrap all your elements in a nice little compact box-model that will give you the width you want, like so... …
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
In this tutorial viewers will learn how add a full-size background image to a webpage using CSS3. Create a new HTML document with an internal stylesheet.: In CSS, define the html element to have a background image. Use a high resolution image.: In t…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question