Created
March 19, 2014 15:14
-
-
Save JLevstein/9643850 to your computer and use it in GitHub Desktop.
Another way of centering content vertically. From http://jsfiddle.net/chdhmphry/LE4jy/ and http://chdhmphry.com/using-pseudo-classes-to-vertically-align-any-content-inside-a-container
This file contains hidden or 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="center-contain"> | |
<div class="center-this"> Everything in this div will be centered in IE8 or greater</div> | |
</div> |
This file contains hidden or 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
.center-contain{ | |
display:block; | |
height: 300px; | |
white-space: nowrap; /* prevents linebreaking */ | |
overflow: hidden; /* hides overflow */ | |
} | |
.center-contain:after{ | |
content: ''; | |
display: inline-block; | |
height: inherit; | |
vertical-align: middle; | |
width:0; | |
} | |
.center-contain > .center-this{ | |
display: inline-block; | |
width:100%; | |
white-space: normal; /* enables linebreaking */ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment