NameSilo

Centering using CSS in ie

Spaceship Spaceship
Watch
Impact
13
I have just created a css site with no tables. However im having a problem centering the content in internet explorer. My site looks fine in Firefox but in Internet Explorer it all displays on the left hand side of the screen. Below is the code from the site. If you want to see the site you can here

style sheet:

HTML:
html, body {
	background: #DEDEDE;
	margin: 0px;
	padding: 0px;
	font-family: Tahoma, Geneva, Arial, Helvetica, sans-serif;
	font-size: 10px; 
	text-align: center; /*for IE stupidity*/
}

#container {
    text-align: left;
}

.logo {
	z-index:2;
	background-color: #FFFFFF;
	border: 5px solid #CC9999;
	font-size: 11px;
    margin-left: auto;
    margin-right: auto;
    left: 0;
    right: 475px;
	width: 350px;
	height: 80px;
	position:absolute;
	top:25px;

}

.maintable {
	z-index:1;
	border: 5px solid #996666;
	font-size: 11px;
    margin-left: auto;
    margin-right: auto;
    left: 0;
    right: 0;
	width: 768px;
	height: 514px;
	position:absolute;
	top:45px;

}

.text {
	z-index:2;
	background-color: #FFFFFF;
	border: 5px solid #CC9999;
	padding: 2px;
	font-size: 11px;
    margin-left: auto;
    margin-right: auto;
    left: 450px;
    right: 0;
	width: 403px;
	height: 315px;
	position:absolute;
	top:312px;

}

.links {
	z-index:2;
	background-color: #FFFFFF;
	border: 5px solid #CC9999;
	padding: 2px;
	font-size: 11px;
    margin-left: auto;
    margin-right: auto;
    left: 0;
    right: 375px;
	width: 389px;
	height: 50px;
	position:absolute;
	top:577px;

}

.footer {
	position:absolute;
	margin-left: auto;
    margin-right: auto;
	left: 0;
    right: 0;
	top:650px;
	z-index:2;
	text-align: center;
	background-color: #FFFFFF;
	border: 2px solid #996666;
	font-size: 11px;
	width: 771px;
	height: 20px;
	padding: 2px;
	padding-top:2px;
}

img {
	border: 0px;
}

page code:

HTML:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>applewave.com</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<link rel="stylesheet" type="text/css" href="styles.css">
</head>

<body>
<div id="container">
			<div class="logo">
				<a href="./index.html"><img src="./images/logo.gif" height="80px" width="350px" alt="logo image"></a>
			</div>

			<div class="maintable">
				<img src="./images/home.gif" height="514px" width="768px" alt="home image">
			</div>

			<div class="links">
				<a href="./portfolio.html"><img src="./images/nav_01.gif" height="50px" width="135px" alt="portfolio link"></a><img src="./images/nav_02.gif" height="50px" width="10px" alt="spacer1"><a href="./services.html"><img src="./images/nav_03.gif" height="50px" width="127px" alt="services link"></a><img src="./images/nav_04.gif" height="50px" width="12px" alt="spacer2"><a href="./contact.html"><img src="./images/nav_05.gif" height="50px" width="99px" alt="services link"></a>
			</div>

			<div class="text">
				<b>Welcome to applewave.com</b><br /><br />
					Applewave is a online co-operation which focus on online site 
					creation, management and also other amenities within the online 
					web industry.<br>
					<br>
					We currently offer a host of services which you can find by 
					looking at the service page of this site. You can find sites 
					that we have created and/or helped with design by looking at the 
					Portfolio page of the site.<p>We also run a bunch of our own 
					websites run by our own administration team. You can check these 
					out by looking up under the sites page here at applewave.com</p>
					<p>If you have any questions or comments about our services or 
					indeed any of our websites then please use the contact form and 
					we will get back to you.<br>
					<br>
					At applewave we also offer free hosting for special causes 
					(charities, personal sites etc) so if you think you qualify get 
					in touch with us today.<br>
					<br>
					Thanks for taking the time to look at our site. We wish you the 
					best with your online ventures
			</div>

			<div class="footer">
				<img src="./images/footer.gif" alt="footer image" width="771px" height="20px">
			</div>
</div>
</body>

</html>

Thanks to anyone who maybe able to help!
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
Watch this example: http://glish.com/css/3.asp. I always start with this layout. It works in every browser and its valid CSS/XHTML.
 
1
•••
HTML:
margin-left:auto;margin-right:auto;

-Steve
 
0
•••
stscac said:
HTML:
margin-left:auto;margin-right:auto;

-Steve

Ive tried this and it hasnt seemed to have worked (you can see the code implemented on the site if you want to see if ive done it correctly.
Thanks.
 
0
•••
You need to add
Code:
margin: 0 auto;
to #container, and also specify a width. Without a width specified, the layout won't be centered correctly in IE.
 
0
•••
To center block level elements (such as DIV), you set the left and right margins to auto, and specify a width. To center its inline content, use text-align:center.
 
0
•••
What do you do when you want the width to be centered on multiple browsers. With the width set to 100% it never works.
 
0
•••
With the width set to 100%, it's already centered in the browser window.
By the way your html doesn't validate, so you might want to look for the problem (I think you're missing a /DIV tag)
 
0
•••
Just set the width to 780px, it'll get you close enough to being centered :)
 
0
•••
i had this problem on one of my first templates, ill look to see how i fixed it but i think Epic is right
 
0
•••
Yes, Epic is correct, its a very annoying problem with IE but the only way to get round it.

Remember to put text-align: left; to make the text stay to the left, I've found that if you dont it centers the text too.

Rick
 
0
•••
Unstoppable Domains
Domain Recover
DomainEasy โ€” Zero Commission
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back