Posted By

icecreamboyy on 03/11/11


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Some0ne


Exactly Center an Image/Div Horizontally and Vertically


 / Published in: CSS
 

  1. .center {
  2. width: 300px;
  3. height: 300px;
  4. position: absolute;
  5. left: 50%;
  6. top: 50%;
  7. margin-left: -150px;
  8. margin-top: -150px;
  9. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: Some0ne on March 11, 2011

Not much explaination though i guess it is just a snippet ...

basiclly m-l is - half width and m-t is - half height

though i would use just 1 line rather then 2:

margin:-150px 0 0 -150px;

You need to login to post a comment.