Skip to content

Instantly share code, notes, and snippets.

@eli-oat
Last active June 5, 2018 19:53
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 eli-oat/d2c0813356d46e38357e3a50d3f898da to your computer and use it in GitHub Desktop.
Save eli-oat/d2c0813356d46e38357e3a50d3f898da to your computer and use it in GitHub Desktop.
Because I can never remember how to vertically center a div...
.outer {
display: table;
position: absolute;
height: 100%;
width: 100%;
}
.middle {
display: table-cell;
vertical-align: middle;
}
.inner {
margin: 0 auto;
width: 400px; /* or whatever else you'd like */
}
/*
Shout out to: https://stackoverflow.com/a/6182661 and http://tachyons.io/components/layout/full-screen-centered-title/index.html
*/
<div class="outer">
<div class="middle">
<div class="inner">
<h1>The Content</h1>
<p>Once upon a midnight dreary...</p>
</div>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment