Help Centering Layout

Discussion in 'CSS' started by Sleepy_Sentry, Jun 17, 2006.

  1. #1
    Sleepy_Sentry, Jun 17, 2006 IP
  2. danielbruzual

    danielbruzual Active Member

    Messages:
    906
    Likes Received:
    57
    Best Answers:
    0
    Trophy Points:
    70
    #2
    div#page {
    margin: auto;
    text-align: center;
    }
     
    danielbruzual, Jun 17, 2006 IP
  3. Sleepy_Sentry

    Sleepy_Sentry Well-Known Member

    Messages:
    869
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    110
    #3
    No luck :( .

    I have my layout sizes in pixels and spacing for some items is set using left:xxx px. Could this be why it isn't working? If so, what can I do to fix this?
     
    Sleepy_Sentry, Jun 17, 2006 IP
  4. Vewgle

    Vewgle Active Member

    Messages:
    121
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #4
    have you tried to make a 1x1 table and put your site in it? Like this...

    <body>
    <table border="1" align="center">
      <tr>
        <td>This is where the website goes. </td>
      </tr>
    </table>
    
    </body>
    Code (markup):
     
    Vewgle, Jun 17, 2006 IP
  5. Sleepy_Sentry

    Sleepy_Sentry Well-Known Member

    Messages:
    869
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    110
    #5
    That doesn't work either, thanks for trying though.

    Either way, HTML center values do not work on CSS pages.
     
    Sleepy_Sentry, Jun 17, 2006 IP
  6. rosytoes

    rosytoes Peon

    Messages:
    230
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #6
    try deleting margin-left: 0px; margin-right: 0px; from the <body> tag?
     
    rosytoes, Jun 17, 2006 IP
  7. AdamSee

    AdamSee Well-Known Member

    Messages:
    422
    Likes Received:
    28
    Best Answers:
    0
    Trophy Points:
    135
    #7
    AdamSee, Jun 17, 2006 IP
  8. Sleepy_Sentry

    Sleepy_Sentry Well-Known Member

    Messages:
    869
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    110
    #8
    Thanks for reminding me to validate my code and add a doctype! I can't believe I forgot!

    Either way, I already fixed my problem. Using position: relative and margin: 0 auto fixed it!
     
    Sleepy_Sentry, Jun 18, 2006 IP