2010-12-10

Vertically center content with CSS

I found a very easy and effective way to center a div vertically with CSS: http://www.vdotmedia.com/blog/vertically-center-content-with-css/

Basically it makes the div behave like a table then sets the vertical alignment to middle.

#container 

    width: 100%; height: 100%; display: table; 
}

#position

{
    display: table-cell; 
    vertical-align: middle; 
    width: 100%; 
    text-align: center; 
}

No comments: