Vertically center content in a 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
<div class="box"> | |
<span class="vertically-centered"> | |
<h3>Nulla a libero metus intege reget tempor gravida</h3> | |
</span> | |
</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
.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