Positioning
element at center of screen

The easy way, if you have a fixed width and height:

#divElement{
    position: absolute;
    top: 50%;
    left: 50%;
    margin-top: -50px;
    margin-left: -50px;
    width: 100px;
    height: 100px;
}​

Please don’t use inline styles! Here is a working example http://jsfiddle.net/S5bKq/.

Leave a Comment