Last active
August 29, 2015 14:20
-
-
Save nikitaeverywhere/304955d212b081757be3 to your computer and use it in GitHub Desktop.
Pure CSS solution for centering content always on middle center of parent relative block.
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
/* | |
Pure CSS solution for centering content always on middle center of parent relative block. | |
*/ | |
.central { | |
position: absolute; | |
left: 0; | |
top: 0; | |
width: 100%; | |
height: 100%; | |
display: table; | |
} | |
.central > div { | |
display: table-cell; | |
vertical-align: middle; | |
text-align: center; | |
} | |
.central > div > div { | |
display: inline-block; | |
} |
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 style="position: relative; height: 100%;"> <!-- Any position:relative block or body --> | |
<div class="central"> | |
<div> | |
<div> | |
Here goes centered content! | |
</div> | |
</div> | |
</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment