Posted By

fackz on 03/30/12


Tagged

div center centered horizontal vertical


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

thomasansems
doubleudet
fackz
ruijscosta


vertical horizontal centered div


 / Published in: CSS
 

Here's a simple way to get your div always on center in any screen size. margins should be half of width and height.

  1. .centerDiv{
  2. width:968px;
  3. height:600px;
  4. background:#ccc;
  5. position:absolute;
  6. margin-top:-300px;
  7. margin-left:-484px;
  8. top:50%;
  9. left:50%;
  10. }

Report this snippet  

You need to login to post a comment.