Log in

View Full Version : Centering using <Container> scripting



CUMidshipmen
12-19-2006, 12:41 AM
Okay... so I'm having a go with creating a two column webpage using css and who knows how long it's been since I've played with CSS. Well. I'm trying to center the entire page (along with the top portion staying in alignment) but have not been able to figure it out. I've read several tutorials about the whole container scrip but it seems alien to me.

http://zero_monolith.sitesled.com is the site under investigation. Any help would be greatly appreciated.:D

jscheuer1
12-19-2006, 05:30 AM
The basic idea is to not mess with the body's margin other than to zero it out if desired. You can use a container division with a unique id that holds all the content on the page:


<body>
<div id="containerdiv">
all content here
</div>
</body>

Use a valid DOCTYPE and avoid all absolute and relative positioning and floats in the content unless you know what you are doing with them. Pick a width for the container - say, 775px, set its style like so:


#containerdiv {
width:775px;
margin:0 auto;
}

As long as no individual element in the content is greater than that width and all content can wrap if it needs to, that will center it.

mwinter
12-19-2006, 01:45 PM
Be aware that the style sheet you attempt to import, all.css, doesn't exist.

Your server misbehaves, here: rather than returning a 404 File Not Found response, it returns a 302 Found redirect that leads to a 200 OK response that pretends to be a 404 document. Status codes should be accurate and actually report the condition. Neither of the received responses are correct.

Mike