Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Jan 2010
    Location
    Canada
    Posts
    34
    Thanks
    11
    Thanked 4 Times in 4 Posts

    Text not in center of page

    Hey!

    I'm working on a layout here for somebody: http://pinkcottoncandy.net/new.php

    I have two problems with CSS I can't figure out. First the layout isn't completely centered. And second the text for the page content isn't completely centered. If anyone knows how to fix both/one of these errors please let me know.

  • #2
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,675
    Thanks
    22
    Thanked 1,827 Times in 1,811 Posts
    Hello Cloud Ghost,
    Good job on the valid code! There is one error in your CSS, no such thing as float:top;

    You should take a look at a simple two column demo for a basic layout to follow.
    In your code, you put 752px wide #header inside 706px wide #container ... the box model shows how to figure your widths so things fit inside their containing divs.

    Try making these changes to your CSS -
    Code:
    body {
       text-align:center;
       font-size:13px;
       font-family:Trebuchet MS;
       background:#2ff5ff;
    margin: 0; /*zero out padding in body so you don't need negative margin to pull #container back up*/
    }
    
    #container {
    width:752px; /*a width that actually contains your site*/
       font-size:13px;
       font-family:Trebuchet MS;
       background-image: url(http://pinkcottoncandy.net/images/pcc_bg.jpg);
    margin:0 auto;
    }
    
    #header {
       width:752px;
    }
    
    #admin {
       width:700px;
       /*float:top; no such thing*/
    }
    
    #content {
    margin: 0 50px 0 170px; /*margined over to make room for #sidebar*/
       color:#000;
    }
    
    #sidebar {
    width:170px;
       float:left;
       text-align:left;
       list-style-type: none;
    }
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

  • Users who have thanked Excavator for this post:

    Cloud Ghost (03-21-2010)

  • #3
    New Coder
    Join Date
    Jan 2010
    Location
    Canada
    Posts
    34
    Thanks
    11
    Thanked 4 Times in 4 Posts
    Thanks Excavator! Just one more problem. Now the page content is under the sidebar content: http://pinkcottoncandy.net/new.php

  • #4
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,675
    Thanks
    22
    Thanked 1,827 Times in 1,811 Posts
    Compare your version to the one I posted. You'll see yours still has the width and float... remove those two lines.
    Like this -
    Code:
    #content {
     /*  width:520px;
      float:right; */
       color:#000;
       margin: auto 50px 0 170px;
    }
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •