cliveportman/code

Centre element vertically and horizontally with CSS

If the element is of a specific size, use fixed positioning combined with negative margins:

#whatever {
position: fixed; top: 50%; left: 50%;
width: 800px; height: 400px;
margin-left: -400px; margin-top: -200px;
}

Note the negative margins are exactly half the width/height.