Created
January 7, 2016 05:29
-
-
Save mugukamil/86dd01db7d8f167391ee to your computer and use it in GitHub Desktop.
Centering a DIV of Unknown Width You can easily center a DIV by using margin:auto; property when you have mentioned its width in your CSS. But in case you wanted to center a DIV with unknown width, here is the code to do so :
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
.content { | |
margin: 0 auto 8px; | |
display: table; | |
} | |
.content div { | |
display: table-cell; | |
} | |
<!--[if IE]> | |
.content { | |
display: block; | |
text-align: center; | |
} | |
.content div { | |
display: inline; | |
zoom: 1; | |
} | |
<![endif]--> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment