Return to Snippet

Revision: 58399
at July 13, 2012 01:05 by mdrisser


Initial Code
/* CSS background-image Technique */

html { 
   width:100%; 
   height:100%; 
   background:url(logo.png) center center no-repeat;
}

/* CSS + Inline Image Technique */

img {
   position: absolute;
   top: 50%;
   left: 50%;
   width: 500px;
   height: 500px;
   margin-top: -250px; /* Half the height */
   margin-left: -250px; /* Half the width */
}

/* Table technique */

html, body, #wrapper {
   height:100%;
   width: 100%;
   margin: 0;
   padding: 0;
   border: 0;
}
#wrapper td {
   vertical-align: middle;
   text-align: center;
}

/*
<html>
<body>
   <table id="wrapper">
      <tr>
         <td><img src="logo.png" alt="" /></td>
      </tr>
   </table>
</body>
</html>
/*

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

Initial Description
From css-tricks.com

Initial Title
Absolute Center (Vertical & Horizontal) an Image

Initial Tags

                                

Initial Language
CSS