?
Solved

Adsense Responsive in the center

Posted on 2014-09-11
1
Medium Priority
?
215 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 2000 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

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 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 …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

770 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