Well, your CSS for centering the #centered
element is in fact correct! So don't worry, you were on the right track there.
The problem actually lies with the content of the #centered
element - the styling of the .content
element. It is given position:absolute
, which means it gets taken out of the layout, and as such the positioning of #centered
has no effect over it (since #centered
does no have position:relative
).
There are two ways to fix this that I can see right now: First, you could add position:relative
to the definition for #centered
, so your CSS looks like this:
#centered {
width:900px;
height:auto;
margin:0px auto;
position:relative;
}
This will cause your absolutely-positioned .content
to be positioned relative to the #centered
element. Alternatively (and the approach I prefer), you can remove the absolute positioning on .content
, since it doesn't seem to needed to be there. With removal of some other attributes rendered unnecessary and adding of a margin instead, it would look like this:
.content {
margin-top:115px;
background:none;
}
Here's a JSFiddle demonstration of the second solution. If you expand the viewport, you'll see that the elements are now centered in the screen. Note that if the content you're inserting server-side won't be absolutely positioned (or rather, will be in the flow of the document), the margin-top:115px
isn't even necessary, since any content you add will simply push the .content
element downwards as needed.
If this isn't what you were looking for, let me know and I'll be happy to help further. Good luck!