maxwidth and centered.

Discussion in 'CSS' started by Guitarkalle, Aug 28, 2007.

  1. #1
    Hello!

    in my page I have a min-width so that my page stops "shrinking" for 800x600 resolution. I have a max-width because I do not want the page to stretch all the way on higher resolutions like 1440x900. However, this makes a "white space" on the right of my page. How can I make the page centered so that it will have equal "white space" on each side of the page?

    What I really want is a margin-left:5% and margin-right:5%, but this will make the page too wide in 800x600 because there is still a small white space on the sides.
     
    Guitarkalle, Aug 28, 2007 IP
  2. just-4-teens

    just-4-teens Peon

    Messages:
    3,967
    Likes Received:
    168
    Best Answers:
    0
    Trophy Points:
    0
    #2
    try something like

    margin-left:5%; margin-right:5%; margin:auto;
     
    just-4-teens, Aug 28, 2007 IP
  3. Guitarkalle

    Guitarkalle Peon

    Messages:
    89
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    did the trick :) margin-left:auto; margin-right:auto; also worked!
     
    Guitarkalle, Aug 28, 2007 IP
  4. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #4
    Just be warned IE 5.x doesn't do margin:auto - but div's in it obey text-align:centered so you can 'fake' it kind of.

    But being IE6 and earlier don't have min-width and max-width, not centering in legacy browsers is probably the least of your problems.
     
    deathshadow, Aug 28, 2007 IP