Results 1 to 9 of 9
  1. #1
    Join Date
    Aug 2006
    Posts
    6,572
    Tokens
    584

    Latest Awards:

    Default Centre this style.css? REP+6

    I was wondering is it possible for anyone to centre all of this.

    At the moment it seems to be a bit on the left and I would prefer it in the middle.

    If you can I will rep+ 6.

    Thanks.

    Code:
    @charset "utf-8";
    
    body {
    background-image: url(images/bg.PNG);
    margin: auto;
    margin-left:0px;
    margin-right:0px;
    }
    
    .wrapper {
    width: 100%px;
    }
    
    #top {
    background-image: url(images/top.gif);
    width: 100%px;
    height: 24px;
    padding-top: 9px;
    padding-left: 11px;
    font-size: 10px;
    font-family: Verdana;
    color: #FFFFFF;
    margin: 0 auto;
    text-align: center;
    }
    
    #banner {
    background-image: url(images/banner.PNG);
    width: 902px;
    height: 151px;
    margin-left: 60px;
    }
    
    #left_container {
    width: 209px;
    float: left;
    margin-left: 60px;
    margin-top: 0px;
    }
    
    #box1 {
    background-image: url(images/box1.PNG);
    margin-top: 10px;
    width: 199px;
    height: 26px;
    padding-left: 10px;
    padding-top: 10px;
    font-size: 10px;
    font-family: Tahoma;
    font-weight: bold;
    color: #FFFFFF;
    }
    
    #box2 {
    background-image: url(images/box2.PNG);
    width: 193px;
    padding-left: 8px;
    padding-right: 8px;
    font-size: 9px;
    font-family: Verdana;
    color: #000000;
    }
    
    #box3 {
    background-image: url(images/box3.PNG);
    height: 10px;
    width: 209px;
    }
    
    #middle_container {
    width: 456px;
    float: left;
    margin-left: 13px;
    }
    
    #cont1 {
    background-image: url(images/cont1.PNG);
    width: 436px;
    padding-left: 10px;
    padding-right: 10px;
    padding-top: 8px;
    font-family: Verdana;
    font-size: 10px;
    color: #000000;
    }
    
    #cont2 {
    background-image: url(images/cont2.PNG);
    width: 421px;
    height: 83px;
    padding-left: 20px;
    padding-right: 15px;
    padding-top: 16px;
    font-family: Verdana;
    font-size: 9px;
    color: #777777;
    text-align: center;
    }
    
    #right_container {
    width: 209px;
    float: left;
    margin-left:15px;
    margin-top: 0px;
    }
    
    #box1 {
    background-image: url(images/box1.PNG);
    margin-top: 10px;
    width: 199px;
    height: 26px;
    padding-left: 10px;
    padding-top: 10px;
    font-size: 10px;
    font-family: Tahoma;
    font-weight: bold;
    color: #FFFFFF;
    }
    
    #box2 {
    background-image: url(images/box2.PNG);
    width: 193px;
    padding-left: 8px;
    padding-right: 8px;
    font-size: 9px;
    font-family: Verdana;
    color: #000000;
    }
    
    #box3 {
    background-image: url(images/box3.PNG);
    height: 10px;
    width: 209px;
    }
    Last edited by efq; 13-06-2009 at 10:09 PM.

  2. #2
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    38
    Tokens
    0

    Default

    .wrapper {
    width 100%px;
    margin-left: auto;
    margin-right: auto;
    }


    ?

  3. #3
    Join Date
    Aug 2006
    Posts
    6,572
    Tokens
    584

    Latest Awards:

    Default

    Quote Originally Posted by Baioslaio View Post
    .wrapper {
    width 100%px;
    margin-left: auto;
    margin-right: auto;
    }


    ?
    Nope, didn't work. I don't think anything changed. REP+ for trying though.

  4. #4

    Default

    Why have you got
    Code:
    width: 100%px;
    you either use percentage or pixels, or another unit. And yeah, to align it center you'd add
    Code:
    margin: 0 auto;
    to the wrapper. If it doesn't work it's because you probably triggered quirks mode and that's often caused by no doctype.
    Last edited by Iszak; 13-06-2009 at 10:16 PM.

  5. #5
    Join Date
    Aug 2006
    Posts
    6,572
    Tokens
    584

    Latest Awards:

    Default

    Quote Originally Posted by Iszak View Post
    Why have you got
    Code:
    width: 100%px;
    you either use percentage or pixels, or another unit. And yeah, to align it center you'd add
    Code:
    margin: 0 auto;
    to the wrapper. If it doesn't work it's because you probably triggered quirks mode and that's often caused by no doctype.
    I added it so its now
    Code:
    body {
    background-image: url(images/bg.PNG);
    margin: auto;
    margin-left:0px;
    margin-right:0px;
    margin: 0 auto;
    }
    but nothing changed. Quirks mode btw?

  6. #6

    Default

    God.. dont' just add all the code people throw at you, you only need margin: 0 auto; and it's to the .wrapper not the body. Also quirks mode can be read about here http://en.wikipedia.org/wiki/Quirks_mode

  7. #7
    Join Date
    Aug 2006
    Posts
    6,572
    Tokens
    584

    Latest Awards:

    Default

    Quote Originally Posted by Iszak View Post
    God.. dont' just add all the code people throw at you, you only need margin: 0 auto; and it's to the .wrapper not the body. Also quirks mode can be read about here http://en.wikipedia.org/wiki/Quirks_mode
    You did say body in the post above then edited it

    But nope, still doesn't work and i'll just look at that page.

  8. #8
    Join Date
    Aug 2004
    Location
    UK
    Posts
    11,283
    Tokens
    2,031

    Latest Awards:

    Default

    In addition to having its margins set auto you also need to set a width on the wrapper

    for example:
    margin: 0 auto;
    width:900px;

    Else the thing will be centered, but you wont be able to tell as its page width anyway

  9. #9
    Join Date
    Aug 2006
    Posts
    6,572
    Tokens
    584

    Latest Awards:

    Default

    That sorta helped although the 3 boxes on the right of the main content is under the main content.

    Edit: Nevermind, changed it from 900 to 1000 and wala.

    Thanks everyone, rep+ added to everyone.
    Last edited by efq; 13-06-2009 at 11:08 PM.

Posting Permissions

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