Last active
October 22, 2016 00:45
-
-
Save andrew--grant/e3f9a66e2d381acd0824140278f60335 to your computer and use it in GitHub Desktop.
How To Centre an Absolutely Positioned Element
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
<style> | |
#content { | |
position: absolute; | |
left: 0; | |
right: 0; | |
margin-left: auto; | |
margin-right: auto; | |
width: 100px; /* Needs a specific value to work */ | |
} | |
</style> | |
<body> | |
<div> | |
<div id="content"> | |
I'm the content | |
</div> | |
</div> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment