Created
March 28, 2016 07:39
-
-
Save ron4stoppable/6fba4de52d85f335c72c to your computer and use it in GitHub Desktop.
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
/* | |
* Horizontally center a div within a div using CSS | |
*/ | |
#inner-new { | |
margin: 0 auto; | |
} | |
/* | |
* If you are targeting IE8+, it might be better to have this instead: | |
*/ | |
#inner-ie { | |
display: table; | |
margin: 0 auto; | |
} | |
/* | |
* If you don't want to set a fixed width on the inner div you could do something like this | |
*/ | |
#outer { | |
width: 100%; | |
text-align: center; | |
} | |
#inner { | |
display: inline-block; | |
} | |
/* the last solution works best with padding */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Various CSS tricks to align div horizontally inside another div tag.