Vertically Align Div in Center of page

Posted on 2009-04-30
Last Modified: 2012-05-06

I have created a holding page for a website which consists of a 900x550px div positioned on a black body background. I have managed to achieve horizontal centralising by specifying the width in the CSS and then applying automatic margins, but I also wish to align the div centrally vertically as well.

This is my current HTML structure:

<div id="container"></div>

The 'container' div is what i want aligning centrally vertically. Does anybody know of a CSS method that will achieve this?

Question by:rob22888
    LVL 5

    Expert Comment


    For information on vertical aligning, look at the following site.
    Method 1 seems to apply here.

    LVL 42

    Accepted Solution

    Since you're using a fixed height, you could also use this technique:

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
    SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
    In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
    In this tutorial viewers will learn how to style different bullet points for unordered lists in CSS. Begin with a normal unordered list; the default bullet point is a solid circle: In the CSS, create a defined class of unordered list by typing "ul.S…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now