CSS - Center an image Vertically & Horizontally on page


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



Copy this code and paste it in your HTML
  1. /* Class for the image to be centered */
  2.  
  3. .centered{
  4. width:1024px;
  5. height:641px;
  6. position:absolute;
  7. left:50%;
  8. top:50%;
  9. margin:-320px 0 0 -512px; /* Adjust as needed to center */
  10. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.