Solved

Adsense Responsive in the center

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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 different bullet points for unordered lists in CSS. Begin with a normal unordered list; the default bullet point is a solid circle: In the CSS, create a defined class of unordered list by typing "ul.S…

762 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now