Return to Snippet

Revision: 28752
at July 14, 2010 02:26 by iqwebdev


Initial Code
.center {
   width: 300px;
   height: 300px;
   position: absolute;
   left: 50%;
   top: 50%;
   margin-left: -150px;
   margin-top: -150px;
}

Initial URL

                                

Initial Description
Negative margins are exactly half the height and width, which pull the element back into perfect center. Only works with elements of a fixed height/width.

Initial Title
CSS Centering and Image/Div Hor & Ver

Initial Tags

                                

Initial Language
CSS