Return to Snippet

Revision: 16413
at August 3, 2009 15:26 by ishottheserif


Initial Code
/* CSS Document */
.centered_div {
width: 100px;
height: 100px;
position: absolute;
top: 50%;
left: 50%;
margin-left: -50px;
margin-top: -50px;
background: red;
}

Here is another example with size 500 x 200 px.

/* CSS Document */
.centered_div {
width:500px;
height: 200px;
position: absolute;
top: 50%;
left: 50%;
margin-left: -250px;
margin-top: -100px;
background: red;
}

Initial URL
http://www.dezinerfolio.com/2007/05/02/the-simplest-way-to-horizontally-and-vertically-center-a-div

Initial Description


Initial Title
The simplest way to horizontally and vertically center a DIV

Initial Tags
center

Initial Language
CSS