Skip to content

Instantly share code, notes, and snippets.

@JLevstein
Created March 19, 2014 15:14
Show Gist options
  • Save JLevstein/9643850 to your computer and use it in GitHub Desktop.
Save JLevstein/9643850 to your computer and use it in GitHub Desktop.
<div class="center-contain">
<div class="center-this"> Everything in this div will be centered in IE8 or greater</div>
</div>
.center-contain{
display:block;
height: 300px;
white-space: nowrap; /* prevents linebreaking */
overflow: hidden; /* hides overflow */
}
.center-contain:after{
content: '';
display: inline-block;
height: inherit;
vertical-align: middle;
width:0;
}
.center-contain > .center-this{
display: inline-block;
width:100%;
white-space: normal; /* enables linebreaking */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment