Skip to content

Instantly share code, notes, and snippets.

@mugukamil
Created January 7, 2016 05:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mugukamil/86dd01db7d8f167391ee to your computer and use it in GitHub Desktop.
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 :
.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