Solved

Adsense Responsive in the center

Posted on 2014-09-11
1
212 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…

739 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