Solved

Adsense Responsive in the center

Posted on 2014-09-11
1
213 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

As a result of several questions about how to use Bootstrap I thought it would be a good idea to write down the development aspect of creating a Bootstrapped website in as little time as possible. Part 1 of this article will only concentrate on g…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
In this Micro Tutorial viewers will learn how to create a CSS image sprite (In a later tutorial, viewers will learn how to use CSS and HTML to create a navigation menu using this sprite) Open a new Photoshop document with a width of (Icon width)x(N…
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …

717 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