PDA

View Full Version : How to make pages not span whole window


lateforwork2
11-14-2007, 01:57 AM
Just trying to figure out how to make pages not span the whole window. I dont know where to change the setting. Thanks.

-Evan

lateforwork2
11-15-2007, 07:24 PM
Anyone have an idea? Its probably a lot more complicated than I think it is, but hopefully someone can give me an idea. Thanks!

Cary
11-16-2007, 12:59 AM
One way is to place the page in a fixed-width, centered div.

You'd add the "wrapper" div to your html like this:

<body>
<div id="wrapper">

... all your original page code ...

</div><!-- end of wrapper div -->
</body>


In your style sheet you would add this:

body {
text-align: center; /* to center the page in IE5 (and 6 in quirks mode) */
}

#wrapper {
text-align: left; /* to keep the center styling on the body from affecting anything else */
width: 750px; /* or whatever width you want your page to be */
margin-left: auto; /* the side margins will grow and shrink with the window size to keep the page centered in IE6+ and other browsers */
margin-right: auto;
}

Cary
11-16-2007, 01:07 AM
If you have any absolutely positioned elements on your page(s), then the layout will probably fall apart. In that case it may help to use relative positioning on #wrapper, so you would end up with the following styling for #wrapper.


#wrapper {
text-align: left;
width: 750px;
margin-left: auto;
margin-right: auto;
position: relative;
}