How to center this adsense block properly?

Associate
Joined
29 Apr 2006
Posts
1,456
Hey
Working on a wordpress theme which i placed an Adsense block (728X90) right under the menu/navigation bar.
Now, the adsense seem fine, right in the center as I want it to be, but in IE, it always keeps showing to the left of the page, although I have placed the adsense code within <div align="center">.

any ideas?

Cheers
 
Soldato
Joined
27 Dec 2005
Posts
17,001
Location
Bristol
Google how to centre divs in IE - you basically need two divs, one contained within the other with an auto margin. Also you should be using CSS not align="".
 
Associate
Joined
29 Apr 2006
Posts
1,456
could you tell me what/where to change exactly please? Not a programmer :).
here is the adsense code within the <div> tag:

<div align="center">
<script type="text/javascript"><!--
google_ad_client = "pub-*************";
/* Upper Adsense Code*/
google_ad_slot = "************";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>

And here is the main CSS file:

@charset "utf-8";

body{font-family:Verdana, Arial, Helvetica, sans-serif;font-size:11px;margin:0px;padding:0;background-color:#fbcbe1; direction:rtl;}
img {margin: 0px; padding:0px;border:0px;}
#mainpage {width:900px;margin:0 auto;padding-right:16px;padding-left:16px;background:url('images/mainbg.png') repeat-y;background-color:#FFFFFF;}
h2 {font: 24px Tahoma;color:#000000;margin:0;padding:0;padding-right:10px;}
h3 {font: 24px Tahoma;color:#000000;margin:0;padding:0;padding-right:10px;}
h4 {font: 24px Tahoma;color:#000000;margin:0;padding:0;padding-right:10px;}
.h2{font-family:Arial, Helvetica, sans-serif;line-height:18px;font-size:12px;color:#312E2E;font-weight:700;}
a:link, a:visited, a:active{color:#FF82AB;text-decoration:none;font-weight:bold;}
a:hover{text-decoration:underline;}
input {border:1px solid #303030;vertical-align: middle;}
#header{float:right;height:215px;width:900px;padding:0;background:url('images/headerbg.png') no-repeat;margin:0px;padding:0px;}
#header .title {float:right;}
#header .title h1 {margin:0px;font:50px Verdana;color:#FFFFFF;padding-right:20px;padding-top:20px;}
#header .title h1 a {font-weight:normal;color:#FFFFFF;}
#header .title h1 a:hover {text-decoration:none;}
#header .title h2 {margin:0px;font:17px Verdana;color:#FFFFFF;padding-right:20px;}
#header .search {float:left;padding-top:42px;padding-left:65px;}
.input {border:0px;background:none;height:17px;width:120px;font:12px Verdana;color:#FFFFFF;font-weight:bold;padding-top:3px;}
.submit {border:0px;height:33px;width:33px;}
#menu {height:43px;width:900px;float:left;background:url('images/menubg.png') repeat-x;border-bottom:3px solid #F0F0F0;}
ul.menu{height:43px;line-height:43px;float:left;list-style:none;margin:0px;padding:0;width:898px;border-right:1px solid #8EBD3D;border-left:1px solid #8EBD3D;}
ul.menu li{float:right;list-style-type:none;margin:0;background:url('images/menudiv.png') no-repeat;}
ul.menu li a {float:left;font:14px Tahoma;color:#FFFFFF;text-transform:uppercase;padding-right:20px;padding-left:20px;line-height:38px;padding-top:5px;}
ul.menu li a:hover {text-decoration:none;background:url('images/menuhover.png') repeat-x;}
ul.menu li:hover {}
ul.menu li a:visited {color:#FFFFFF;font-weight:normal;}
#content{font: 12px Tahoma;color:#000000;float:right;width:584px;margin:0px;padding:0;overflow:hidden;padding-right:24px;padding-left:27px;}
.entry{float:right;width:584px;margin:0px;padding:0px;background:url('images/entrybg.png') repeat-y;}
.head {float:right;width:584px;float:right;background:url('images/h2bg.png') no-repeat;}
.date {float:right;width:156px;}
.title {float:right;}
.entry h5 {font:12px Verdana;text-align:center;font-weight:bold;color:#FFFFFF;margin:0px;padding:0;line-height:46px;padding-top:18px;}
.entry h2 {font: 20px Tahoma;color:#FFFFFF;margin:0px;padding:0;line-height:46px;padding-top:18px;height:64px;white-space:nowrap;}
.entry h2 a {text-decoration:none;color:#FFFFFF;margin:0;font-weight:normal;}
.entry h2 a:hover{text-decoration:none;}
.entry h2 a:visited {color:#FFFFFF;font-weight:normal;}
.entry h3 {background:url('images/h3bg.png') no-repeat;font: 20px Tahoma;color:#FFFFFF;margin:0px;padding:0;line-height:46px;padding-top:18px;padding-right:20px;}
.entry h4 {font: 12px Tahoma;color:#000000;margin:0;padding:0;text-align:center;line-height:36px;background:url('images/entrybot.png') no-repeat;}
.entry h4 a {text-decoration:none;color:000000;font-weight:normal;margin:0;}
.entry h4 a:hover {text-decoration:underline;}
.entry p {margin:0px;padding-right:15px;padding-left:13px;padding-bottom:10px;}
#sidebar{float:right;width:243px;margin:0px;padding:0px;font: 11px Verdana;padding-left:22px;}
.rsidebar{font: 13px Verdana;color:#303030;float:left;width:243px;}
.rsidebar h2{font: 18px Tahoma;color:#FFFFFF;padding:0;line-height:37px;padding-right:26px;background:url('images/sidebarh2.png') no-repeat;}
.rsidebar a {font-weight:normal;}
.rsidebar ul{list-style-type:none;margin:0;padding:0;padding-top:18px;}
.rsidebar ul li{list-style-type:none;margin:0 0 0px;padding:0;padding-right:0px;}
.rsidebar ul li ul{list-style-type:square;margin:0;padding:0 0px;background:url('images/sidebarbot.png') no-repeat;background-position:100%% 100%;padding-bottom:22px;}
.rsidebar ul li ul li{list-style-type:none;border:0px none;margin:0;background:url('images/sidebarbg.png') repeat-y;padding-right:25px;padding-left:25px;}
.rsidebar ul li ul li a {font:12px Tahoma;font-weight:normal;color:#9D1000;line-height:25px;}
.rsidebar ul li ul li a:visited {font-weight:normal;}
.rsidebar ul li ul li a:hover {text-decoration:none;color:#05C1E2;}

.navigation{float:right;color:#303030;width:636px;margin:0px;padding:0px;margin-right:13px;margin-left:19px;padding-top:6px;}
.navigation p {color:#303030;margin:0px;}
.navigation a:hover {text-decoration:underline;}
.alignright{float:left;margin-top:10px;}
.alignleft{float:right;margin-top:10px;}
.postmetadata{text-align:left;font: 12px Verdana;color:#600320;margin:0;padding:0px;}
.postmetadata a {color:#600320}
.boxcomments{width:584px;background:url('images/entrybot2.png') no-repeat;background-position:100% 100%;}
#commentform label{display:block;margin:0;padding-top:10px;}
#commentform input{width:170px;margin:0 0 10px 5px;padding:1px;}
#commentform textarea{width:400px;margin:0 0 10px;padding:0;}
#commentform #submit{margin:0 0 0px;}
#commentform p{margin:0px 0;padding-top:5px;}
ol.commentlist{margin:0 0 0 0px;padding:0;background:url('images/entrybot2.png') no-repeat;background-position:100% 100%;}
ol.commentlist li{display:block;list-style:none;margin:0;padding:0px 0px 1px;}
ol.commentlist li.commenthead{display:block;list-style:none;margin:0;padding:0px;}
ol.commentlist li.commenthead h2{margin:0;background:url('images/h3bg.png') no-repeat;padding-right:20px;}
ol.tblist{border-top:1px solid #fff;list-style:none;margin:0 0 1px;padding:15px;}
ol.tblist li{display:block;padding-right:15px;list-style-type:none; margin-right:0; margin-left:0; margin-top:0; margin-bottom:5px;}
#footer{color:#FFFFFF;clear:both;height:0px;margin:0;padding:0;}
#footerbox{color:#FFFFFF;margin:0;padding:0;width:900px;height:63px;margin: 0 auto;background:url('images/footerbg.png') no-repeat;}
#footerbox p {color:#FFFFFF;margin:0px;font-size:12px;margin-top:0px;}
.footer{text-align:center;width:900px;color:#F1DCE3;margin:0 auto;padding:0;}
.footer a:hover{text-decoration:underline;border:none;}
.footer a:link, .footer a:active, .footer a:visited {color:#FFFFFF;border:none;font-weight:normal;}
.footer p {margin:0px;font:12px Tahoma;color:#FFFFFF;line-height:36px;}

/** WORDPRESS CSS */

.aligncenter,
div.aligncenter {
display: block;
margin-right: auto;
margin-left: auto;
}

.aligncenter {
margin: 0 0 10px 0;
}

.alignleft {
float: left;
margin: 0 10px 10px 10px;
}

.alignright {
float: right;
margin: 0 10px 10px 10px;
}

.wp-caption {
border: 1px solid #ccc;
text-align: center;
background-color: #f7f7f7;
padding-top: 4px;
}

.wp-caption img {
float: none;
margin: 0px;
padding: 0px;
border: none;
}

.wp-caption p.wp-caption-text {
font-size: 11px;
line-height: 17px;
padding: 0px;
margin: 0px;
}
 
Soldato
Joined
8 Oct 2005
Posts
4,185
Location
Midlands, UK
Just looking at it, i'd say the line that says "<div align="center">". add a class in your centers the div or if your lazy do it inline E.g. <div style="sjhdashkgdhkasgdk">


Google how to centre divs in IE - you basically need two divs, one contained within the other with an auto margin. Also you should be using CSS not align="".

I always use the old margin:0 auto thing:

Code:
[FONT=Fixedsys]    body {
        text-align: center;
    }
    #container {
        margin: 0 auto;
display: block;
    }[/FONT]
 
Last edited:
Soldato
Joined
30 Sep 2003
Posts
10,914
Location
London
One reason for a div not centring through auto margins in IE is that the page doesn't have a valid DOCTYPE set.
 
Associate
Joined
29 Apr 2006
Posts
1,456
1 more question.
I have placed the adsense code inside the default text widget on the default wordpress theme. but yet again, it FF it looks fine, in IE the ads go to the left of the page, outside the theme borders.
?
any help appreciated :)
 
Top