Created
April 28, 2012 04:50
-
-
Save twinsinsnippet/2516092 to your computer and use it in GitHub Desktop.
CSS: Absolute Center (Vertical & Horizontal) an Image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*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 */ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment