Skip to content

Instantly share code, notes, and snippets.

@stanwmusic
Created March 18, 2014 01:13
Show Gist options
  • Save stanwmusic/9611765 to your computer and use it in GitHub Desktop.
Save stanwmusic/9611765 to your computer and use it in GitHub Desktop.
A Pen by Eric.
<div id="box">
<div id="center">
<h1>
This content is centered vertically in the gray box.
</h1>
<h2>
The gray box has a varying height.
</h2>
<p>
There are multiple elements in the gray box.
</p>
</div>
</div>
@keyframes resize {
0% {
height: 300px;
}
50% {
height: 500px;
}
}
#box {
margin: 20px auto;
width: 50%;
height: 300px;
background-color: #EEE;
padding: 0 20px;
white-space: nowrap;
animation: resize 5s infinite;
}
#center {
vertical-align: middle;
display: inline-block;
white-space: normal;
}
#box:after {
content: "";
width: 1px;
height: 100%;
vertical-align: middle;
display: inline-block;
margin-right: -10px;
}
@stanwmusic
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment