1. Making the page center. Code a wrap div like Eric said, but also with position: relative:-
#wrap { width: 900px; margin: 0 auto; position: relative; }
Then structure your page body section:-
<body>
<div id="wrap">
.........all page content.........
</div>
</body>
Any position: absolute elements inside the #wrap div will probably need the left size edited because position: absolute divs take their position from the top left corner of the position: relative wrap div instead of the top left corner of the window or screen, so when the wrap div moves to center in large resolutions because of margin: auto, the position: absolute divs move with it but retain their positions inside.
2. A page which always fits the window width requires all widths to be in % totaling 100%. That includes all divs, tables, table cells, lists, forms and also side padding and side margin. It also needs all images to be sized in % like:-
<img style="width: 22%;" src="photo1.jpg" alt="Photo 1">
Borders can't be sized in % so if you have side borders in px, total the other items to 97% or 98% to allow for the borders in px.
It's much harder to code a totally fluid page width as content will get squashed up or very spread out. It works best when there isn't much content on the page.
You can use min-width and max-width as an alternative but that doesn't work in IE6.
Last edited by Wickham (January 27, 2010 3:01 pm)