Help with Advertising Alignment

Discussion in 'Web Design and Development' started by eenu, Apr 10, 2007.

  1. eenu macrumors 65816

    eenu

    Joined:
    Aug 11, 2006
    Location:
    Manchester, UK
    #1
    See here:

    http://www.davidjmoore.com/wordpress/becoming-an-early-riser/

    I want to get the google ad at the top of this post aligned in the centre. The code is:

    Code:
    
    <script type="text/javascript"><!--
    google_ad_client = "pub-XXXXXXXXXXXX";
    google_ad_width = 468;
    google_ad_height = 15;
    google_ad_format = "468x15_0ads_al";
    google_ad_channel = "";
    google_color_border = "FFFFFF";
    google_color_bg = "FFFFFF";
    google_color_link = "999999";
    google_color_text = "FFFFCC";
    google_color_url = "999999";
    //-->
    </script>
    <script type="text/javascript" 
      src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script>
    
    
    Come hell or high water i can't seem to get it to centre. I have tried every possible permutation and combination of tags etc that i can think of. Anyone got any ideas?
     
  2. Elixer macrumors regular

    Joined:
    Aug 15, 2006
    #2
    Try this, I dont know if this is the right way since I'm still new at this but it works for me.

    <center><script type="text/javascript"><!--
    google_ad_client = "pub-XXXXXXXXXXXX";
    google_ad_width = 468;
    google_ad_height = 15;
    google_ad_format = "468x15_0ads_al";
    google_ad_channel = "";
    google_color_border = "FFFFFF";
    google_color_bg = "FFFFFF";
    google_color_link = "999999";
    google_color_text = "FFFFCC";
    google_color_url = "999999";
    //-->
    </script>
    <script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script></center>
     
  3. tominated macrumors 68000

    tominated

    Joined:
    Jul 7, 2006
    Location:
    Queensland, Australia
    #3
    NO! DON'T USE THE CENTER TAG FOR GOD'S SAKE! It is extremely depreciated html. Wrap that html/javascript in a div and give it this styling (css):
    Code:
    margin-left: auto; margin-right: auto;
    That should work perfectly fine.

    BTW: sorry for shouting
     
  4. Elixer macrumors regular

    Joined:
    Aug 15, 2006
    #4
    Could you give me an example on how that would look? I should probably go through and change what I did then.
    Edit: Would using <div align="center"> be another option?
     
  5. chepistolas macrumors member

    chepistolas

    Joined:
    Apr 21, 2005
    Location:
    Chicago
    #5
    I had the same problem fixing my adsense yesterday. Except I wanted to push it to the right. This is what I did.
    http://www.luconline.com
    its floated to the right in the middle of the page.

    If you want your adsense code in the middle like this picture: (make sure you reload, my cache doesn't display it right away)
    http://luconline.com/pictures/picture.png
    then read along.

    This goes in your post.
    <code>
    <div id="googleads">
    <script>gogle ads</script>
    </div>
    </code>

    This goes in your css file. Since your using K2 and wordpress, the posts are included in the #primary div, so make sure you put #primary before #googleads. Example.
    This goes in your CSS file:
    #primary #googleads {
    text-align:center;
    padding: 5px; (whatever # of pixels you want for space)
    }

    I did try margin-left:auto; margin-right: auto; and it didn't work. I also tried margin: 0px auto 0px auto; and it didn't work either. I couldn't tell if you are using a square ad or not, since your site gives me a 404 error. If you are using a square ad, your better off just floating it to the right or left and let the surrounding text wrap over the ad, just my opinion.

    Tell me if that works, Cheers.
     
  6. tominated macrumors 68000

    tominated

    Joined:
    Jul 7, 2006
    Location:
    Queensland, Australia
    #6
    that text align thing should only be working on IE. Instead of putting more stuff into the css file, put this code snippet in for the ads:

    Code:
    <div style="margin-left: auto; margin-right: auto;">
    <script type="text/javascript"><!--
    google_ad_client = "pub-XXXXXXXXXXXX";
    google_ad_width = 468;
    google_ad_height = 15;
    google_ad_format = "468x15_0ads_al";
    google_ad_channel = "";
    google_color_border = "FFFFFF";
    google_color_bg = "FFFFFF";
    google_color_link = "999999";
    google_color_text = "FFFFCC";
    google_color_url = "999999";
    //-->
    </script>
    <script type="text/javascript" 
      src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script>
    </div>
     

Share This Page