Advertisement

There's no such thing as a stupid question, but they're the easiest to answer.
Login
Search

Advertisement

Web Design & Development Web Design & Development
Search Search
Search for:
Tech Support Guy > > >

Solved: Centre align AdSense javascript


(!)

JiminSA's Avatar
JiminSA   (Jim) JiminSA is offline JiminSA has a Profile Picture
Computer Specs
Member with 1,551 posts.
THREAD STARTER
 
Join Date: Dec 2011
Location: Johannesburg South Africa
Experience: Intermediate
12-Jun-2012, 03:20 AM #1
Solved: Centre align AdSense javascript
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?
allnodcoms's Avatar
allnodcoms   (Danny) allnodcoms is offline allnodcoms has a Profile Picture
Computer Specs
Member with 606 posts.
 
Join Date: Jun 2007
Location: Hertfordshire - England
Experience: Advanced
12-Jun-2012, 06:33 AM #2
Try:
Code:
margin-left: auto;
margin-right: auto;
Danny
JiminSA's Avatar
JiminSA   (Jim) JiminSA is offline JiminSA has a Profile Picture
Computer Specs
Member with 1,551 posts.
THREAD STARTER
 
Join Date: Dec 2011
Location: Johannesburg South Africa
Experience: Intermediate
12-Jun-2012, 06:41 AM #3
Seems auto and specifying equal px numbers has the same effect. But unfortunately neither of these have centred the javascript???
allnodcoms's Avatar
allnodcoms   (Danny) allnodcoms is offline allnodcoms has a Profile Picture
Computer Specs
Member with 606 posts.
 
Join Date: Jun 2007
Location: Hertfordshire - England
Experience: Advanced
12-Jun-2012, 06:49 AM #4
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
JiminSA's Avatar
JiminSA   (Jim) JiminSA is offline JiminSA has a Profile Picture
Computer Specs
Member with 1,551 posts.
THREAD STARTER
 
Join Date: Dec 2011
Location: Johannesburg South Africa
Experience: Intermediate
12-Jun-2012, 06:59 AM #5
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?
JiminSA's Avatar
JiminSA   (Jim) JiminSA is offline JiminSA has a Profile Picture
Computer Specs
Member with 1,551 posts.
THREAD STARTER
 
Join Date: Dec 2011
Location: Johannesburg South Africa
Experience: Intermediate
12-Jun-2012, 07:04 AM #6
You can stay in the brownies for now Danny I won't be using the td hack - didn't work... nor the iframe...
JiminSA's Avatar
JiminSA   (Jim) JiminSA is offline JiminSA has a Profile Picture
Computer Specs
Member with 1,551 posts.
THREAD STARTER
 
Join Date: Dec 2011
Location: Johannesburg South Africa
Experience: Intermediate
12-Jun-2012, 08:28 AM #7
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 Code:
 <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
allnodcoms's Avatar
allnodcoms   (Danny) allnodcoms is offline allnodcoms has a Profile Picture
Computer Specs
Member with 606 posts.
 
Join Date: Jun 2007
Location: Hertfordshire - England
Experience: Advanced
12-Jun-2012, 08:59 AM #8
Yeah, I just looked at that... Grizzly!

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

Danny
JiminSA's Avatar
JiminSA   (Jim) JiminSA is offline JiminSA has a Profile Picture
Computer Specs
Member with 1,551 posts.
THREAD STARTER
 
Join Date: Dec 2011
Location: Johannesburg South Africa
Experience: Intermediate
12-Jun-2012, 09:08 AM #9
Yup tried that but it didnae graft!
As Seen On

BBC, Reader's Digest, PC Magazine, Today Show, Money Magazine
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.


(clock)
THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


WELCOME
You Are Using: Server ID
Trusted Website Back to the Top ↑