vertical horizontal centered div


/ Published in: CSS
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.