Skip to content

Instantly share code, notes, and snippets.

@matthewhudson
Last active December 18, 2015 08:00
Show Gist options
  • Save matthewhudson/5750910 to your computer and use it in GitHub Desktop.
Save matthewhudson/5750910 to your computer and use it in GitHub Desktop.
Vertical center content with CSS
<div class="container-outer">
<div class="container-middle">
<div class="container-inner">
<p>Hello World!</p>
</div>
</div>
</div>
.container-outer {
width: 100%;
padding: 0;
display: table;
height: 100%;
position: absolute;
top: 0;
left: 0;
margin: 0;
}
.container-middle {
padding: 0;
vertical-align: middle;
display: table-cell;
margin: 0;
}
.container-inner {
width: 700px;
margin: 0 auto;
text-align: left;
padding: 10px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment