Tricky one... I had a requirement to do this a while back, and at the time, the only way I'd found (aside from using tables) was to use "quirks mode" (for IE) by omitting the DOCTYPE, and using some quirky CSS.
Is the 'page' of fixed height?
If so then you can do a thing with negative top and bottom margins.
If not, then imagine the 'page' was of a greater depth than the viewport. How would it center vertically? Would the top of the page poke off the top of the viewport?
Best solution I've found for this is to work on a viewport size I like and then just work out a margin-top percentage that looks ok and live with it.
The only other way I can think of is to use Javascript to get the height of the 'page', work out it's center then get the the height of the viewport, calculate it's center and put the page center on to the viewport center line up. I've no idea if this is even practical, just an idle thought.
ew. in your favorite one all the side navigation comes before the semantical content.
boo to that. if this layout is that important, just do a normal horizontally-centered one and utilize javascript to vertically-center. the small number of people with js disabled will not have the vertical centering, but the horizontal will remain.
I don't know what the content of the centered container has to do with anything. As long as that container is centered. And it is not using any weird absolute positioning, display: table-cell or any other trick like that. Anyway, I just glanced and liked it.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.