Skip to content

Instantly share code, notes, and snippets.

@mpukit
Last active August 29, 2015 14:15
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save mpukit/30a95c2332068a0aea2f to your computer and use it in GitHub Desktop.
Vertically center content in a div
<div class="box">
<span class="vertically-centered">
<h3>Nulla a libero metus intege reget tempor gravida</h3>
</span>
</div>
.box {
width: 100%;
min-height: 370px;
line-height: 370px; /* same as height of the container */
}
.vertically-centered {
display: inline-block;
width: 270px; /* set value so it doesn't overflow */
vertical-align: middle;
line-height: normal;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment