Last active
August 29, 2015 14:02
-
-
Save OmShiv/d4c0f8dc855aea24d095 to your computer and use it in GitHub Desktop.
Vertical Horizontal Center
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="outer"> | |
<div class="middle"> | |
<div class="inner"> | |
<h1>The Content</h1> | |
<p>Once upon a midnight dreary...</p> | |
</div> | |
</div> | |
</div> | |
<style> | |
.outer { | |
display: table; | |
position: absolute; | |
height: 100%; | |
width: 100%; | |
} | |
.middle { | |
display: table-cell; | |
vertical-align: middle; | |
} | |
.inner { | |
margin-left: auto; | |
margin-right: auto; | |
width: /*whatever width you want*/; | |
} | |
/* for IE less than 7 */ | |
.outer { | |
display: inline; | |
top: 0; | |
} | |
.middle { | |
display: inline; | |
top: 50%; | |
position: relative; | |
} | |
.inner { | |
display: inline; | |
top: -50%; | |
position: relative; | |
} | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment