A Pen by Chris Coyier on CodePen.
Forked from anonymous/Centering-in-the-Unknown.markdown
Created
December 12, 2013 07:47
-
-
Save glebcha/7924530 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="block" style="height: 300px;"> | |
<div class="centered"> | |
<h1>Some text</h1> | |
<p>But he stole up to us again, and suddenly clapping his hand on my shoulder, said—"Did ye see anything looking like men going towards that ship a while ago?"</p> | |
</div> | |
</div> | |
<div class="block" style="height: 200px;"> | |
<div class="centered"> | |
<h1>Some text</h1> | |
<p>But he stole up to us again, and suddenly clapping his hand on my shoulder, said—"Did ye see anything looking like men going towards that ship a while ago?"</p> | |
</div> | |
</div> | |
<div class="block" style="height: 600px;"> | |
<div class="centered"> | |
<h1>Some text</h1> | |
<p>But he stole up to us again, and suddenly clapping his hand on my shoulder, said—"Did ye see anything looking like men going towards that ship a while ago?"</p> | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.block { | |
text-align: center; | |
background: #c0c0c0; | |
border: #a0a0a0 solid 1px; | |
margin: 20px; | |
} | |
.block:before { | |
content: ''; | |
display: inline-block; | |
height: 100%; | |
vertical-align: middle; | |
margin-right: -0.25em; /* Adjusts for spacing */ | |
/* For visualization | |
background: #808080; width: 5px; | |
*/ | |
} | |
.centered { | |
display: inline-block; | |
vertical-align: middle; | |
width: 300px; | |
padding: 10px 15px; | |
border: #a0a0a0 solid 1px; | |
background: #f5f5f5; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment