Posted By

Gianino on 11/23/12


Tagged

image center vertical


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

Mench59
snoopmole


Absolute Center (Vertical & Horizontal) an Image


 / Published in: CSS
 

URL: http://css-tricks.com/snippets/css/absolute-center-vertical-horizontal-an-image/

From css-tricks.com

  1. /*CSS background-image Technique*/
  2. html {
  3. width:100%;
  4. height:100%;
  5. background:url(logo.png) center center no-repeat;
  6. }
  7.  
  8. /*CSS + Inline Image Technique*/
  9. img {
  10. position: absolute;
  11. top: 50%;
  12. left: 50%;
  13. width: 500px;
  14. height: 500px;
  15. margin-top: -250px; /* Half the height */
  16. margin-left: -250px; /* Half the width */
  17. }

Report this snippet  

You need to login to post a comment.