1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: Centre align AdSense javascript

Discussion in 'Web Design & Development' started by JiminSA, Jun 12, 2012.

Thread Status:
Not open for further replies.
Advertisement
  1. JiminSA

    JiminSA Thread Starter

    Joined:
    Dec 15, 2011
    Messages:
    2,058
    I have opted to include some Google AdSense slots in one of our sites which is also in Google Adwords. (See if it won't pay for itself!)
    The dynamic "links" are via javascript viz:-
    Code:
    			<div id=ad_slice">
    				<script type="text/javascript"><!--
    				google_ad_client = "ca-pub-1181259325345481";
    				/* Gearbox Repair 1 */
    				google_ad_slot = "0559324299";
    				google_ad_width = 728;
    				google_ad_height = 90;
    				//-->
    				</script>
    				<script type="text/javascript"
    				src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    				</script>
    			</div>
    
    ...for which I have added some css...
    Code:
    #ad_slice
    {
    width:800px;
    text-align: center;
    padding-left:10px;
    padding-right:10px;
    margin-left:10px;
    margin-right:10px;
    }
    
    ...in order to try and centre the feed...but unfortunately it is aligning left and won't centre
    Q.
    How can I centre align such feeds?
     
  2. allnodcoms

    allnodcoms

    Joined:
    Jun 30, 2007
    Messages:
    613
    Try:
    Code:
    margin-left: auto;
    margin-right: auto;
    Danny
     
  3. JiminSA

    JiminSA Thread Starter

    Joined:
    Dec 15, 2011
    Messages:
    2,058
    Seems auto and specifying equal px numbers has the same effect. But unfortunately neither of these have centred the javascript???
     
  4. allnodcoms

    allnodcoms

    Joined:
    Jun 30, 2007
    Messages:
    613
    OK... I'd really need to see some more of the code to come up with 'legit' solution - a link would be good ;)

    Real Dirty Hack Alert: Put the JS in a single celled table and set the <td> to align="centre" - It's nasty (and I'll probably get drummed out of the Brownies for posting it) - but it works...

    Danny
     
  5. JiminSA

    JiminSA Thread Starter

    Joined:
    Dec 15, 2011
    Messages:
    2,058
    http://www.surf4wheels.biz/gearboxes/ - I'm not seeking to advertise either (moderators)...
    I was thinking of an iframe, but a cell will suffice - it's a cosmetics thing I know, but isn't that what design is governed by mostly?
     
  6. JiminSA

    JiminSA Thread Starter

    Joined:
    Dec 15, 2011
    Messages:
    2,058
    You can stay in the brownies for now Danny I won't be using the td hack - didn't work... nor the iframe...
     
  7. JiminSA

    JiminSA Thread Starter

    Joined:
    Dec 15, 2011
    Messages:
    2,058
    I guess this thread should be re-titled "Who can come up with the dirtiest hack" - with this one I think I've won!
    HTML:
    			<div class="displayed" style="position:relative; top: opx; left: 36px">
    				<script type="text/javascript"><!--
    				google_ad_client = "ca-pub-1181259325345481";
    				/* Gearbox Repair 2 */
    				google_ad_slot = "0559324299";
    				google_ad_width = 728;
    				google_ad_height = 90;
    				//-->
    				</script>
    				<script type="text/javascript"
    				src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    				</script>
    			</div>
    
    But it centres it Ok:)
     
  8. allnodcoms

    allnodcoms

    Joined:
    Jun 30, 2007
    Messages:
    613
    Yeah, I just looked at that... Grizzly!

    Have you tried - just asking - "padding-left: 36px;"? Might look slightly nicer when inspected. ;)

    Danny
     
  9. JiminSA

    JiminSA Thread Starter

    Joined:
    Dec 15, 2011
    Messages:
    2,058
    Yup tried that but it didnae graft!
     
  10. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1056744