centering website with CSS

Discussion in 'CSS' started by thosecars82, May 17, 2008.

  1. #1
    Hello there
    I do not know what I am doing wrong but I do not get to center this site www.metatradersoftware.com completely. Although it has moved a bit to the right side since I put the wrapper, it is still staying quite on the left part of the screen. The code looks like this:

    #wrap {
    position: relative;
    width:760px;
    margin-left:auto;
    margin-right:auto;
    }
    ...
    <body>
    <div id="wrap">
    ....
    </div>
    </body>
    </html>

    I would appreciate any ideas to solve this issue, because as far as I seen, this is the standar way of centering a website with css.
    Look for your replies.
    Thanks in advance
     
    thosecars82, May 17, 2008 IP
  2. MoT

    MoT Peon

    Messages:
    97
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hi, the problem is you have set a width to the body element of 800px, remove that and it will work fine.
     
    MoT, May 17, 2008 IP
  3. risoknop

    risoknop Peon

    Messages:
    914
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Exactly.

    If I might add a thing:
    - remove position: relative; - it's bloatcode - not needed
     
    risoknop, May 20, 2008 IP
  4. thosecars82

    thosecars82 Member

    Messages:
    81
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #4
    I guess bloatcode = not really needed.
    Anyways, I will take this suggestion into consideration. Anyways, thanks both of you for your sound suggesions.
    As MOT of you told me, I had to remove the attribut width:800px from the body to get the website centered. And it worked.
     
    thosecars82, May 20, 2008 IP