PDA

View Full Version : Centering Content Div




iMasterWeb
Oct 25, 2009, 12:21 AM
Hi, this is my first try at hand-coding a site, so forgive me if this is a stupid quesiton...

I have my site set up so that there is the page div, which contains the background image that repeats depending on the size of the window. Inside of that div, I have a div where I want the content to be. I tried setting this div's left and right margins to auto so that it stays in the center, but it doesn't move. Any help is appreciated. (You can ignore the two div's inside of the content div because I don't think they're causing the problem) Here is the code:

HTML:<html>
<head>
<LINK REL=StyleSheet HREF="stylesheet.css" TYPE="text/css" MEDIA=screen>
</head>
<body>
<div id = page>
<div id = content>
<div id = header>
<div id = logo>
<img src="Images/logo.jpg" alt="Welcome to iMasterWeb!"/>
</div>
</div>
</div>
</div>
</body>
</html>

CSS:#page {
width: 100%;
height: 970px;
background-image: url("Images/pagebackground.jpg");
background-repeat: repeat-x;
background-color: #999999;
}

#content {
height: 970px;
width: 960px;
float: left;
margin: 0, auto
}

#header {
float: left;
background: #333333;
width: 100%;
height: 175px;
}

#logo {
float: left;
padding: 25px;
margin: 0, 0, 0, 100px;
}



samwich
Oct 25, 2009, 01:12 AM
I believe it should just be

margin:0 auto;

in the content div. the ',' is messing up that declaration

iMasterWeb
Oct 25, 2009, 01:25 AM
I believe it should just be

margin:0 auto;

in the content div. the ',' is messing up that declaration

Thanks for the help! By removing the comma and the float: left; I got it to work! Thanks a lot! :D