Last active
August 29, 2015 13:57
-
-
Save TechFounder/9668187 to your computer and use it in GitHub Desktop.
You want a way to center any object to the middle of the page (horizontal centering)?
This file contains 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
<div id="first"> | |
<div id="second"> | |
Item you want centered | |
</div> | |
</div> | |
for example: | |
<a href="mailto:info@email.com?Subject=Web%20Page" target="_top" id="first"> | |
<img src="photo.png" alt="photo"> | |
</a> |
This file contains 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
#first { | |
position: absolute; | |
left: 50%; | |
} | |
#second { | |
position: relative; | |
left: -50%; | |
} | |
or, from the example: | |
#first { | |
position: absolute; | |
left: 50%; | |
} | |
#first img { | |
position: relative; | |
left: -50%; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment