Click to See Complete Forum and Search --> : CSS Positioning


xplosive
06-03-2004, 01:22 AM
Hey, I have a problem with some CSS positioning commands. I can't get it to center my main content (base of the website). I've seen it on other websites and I've done it before, but I can't seem to do it again. Heres the css commands I am using:

#content {
position: relative;
margin-left: auto;
margin-right: auto;
width: 800px;
}

Then I code my HTML like:

<body>
<div id="content">
<div id="header">&nbsp;</div>
</div>
</body>

Any help would be helpful.

Thanks,
xplosive

Sam
06-03-2004, 01:45 AM
that should work provided you are using a strict enough doctype for IE, and regardless for browsers... perhaps if that's not the problem, you could post your entire source...

xplosive
06-03-2004, 04:56 AM
Heres all the code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">

<html>
<head>
<title>ShutterKits</title>
<link type="text/css" rel="stylesheet" href="site.css">
</head>

<body>
<div id="content">
<div id="header"><img src="images/banner.gif" alt="ShutterKits"></div>
</div>
</body>
</html>

#content {
position: relative;
margin-left: auto;
margin-right: auto;
width: 800px;
}

#header {
position: relative;
border-color: #eddec1;
border-style: dashed;
border-width: 1px;
}

Thats all I've done for now, just been trying to get this damn positioning correct! :)

Fang
06-03-2004, 05:27 AM
Basic contents centering:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>center contents</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
<!--
#text {text-align: center}
#alignment {text-align: left; margin: auto auto; width:800px;}
p {background:red;}
-->
</style>

</head>
<body>
<div id="text"><div id="alignment">
<p>contents</p>
</div></div>
</body>
</html>

xplosive
06-03-2004, 06:04 AM
Sweet it works. Thanks for all the help people.

Thanks,
xplosive