Centering Content Div

Discussion in 'Web Design and Development' started by iMasterWeb, Oct 24, 2009.

  1. iMasterWeb macrumors regular

    Joined:
    Mar 15, 2009
    #1
    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:
    CSS:
    Code:
    #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;
    }
     
  2. samwich macrumors regular

    Joined:
    Aug 5, 2007
    #2
    I believe it should just be

    margin:0 auto;

    in the content div. the ',' is messing up that declaration
     
  3. iMasterWeb thread starter macrumors regular

    Joined:
    Mar 15, 2009
    #3
    Thanks for the help! By removing the comma and the float: left; I got it to work! Thanks a lot! :D
     

Share This Page