Created
August 24, 2012 07:55
-
-
Save artofhuman/3447275 to your computer and use it in GitHub Desktop.
CSS: vertical align
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
HTML: | |
<div class="container"> <!-- блок-контейнер --> | |
<div> <!-- блок с содержанием --> | |
Элемент, который выравнивается вертикально внутри блока-контейнера. | |
</div> | |
<div class="auxiliary"> </div> <!-- пустой вспомогательный блок --> | |
</div> | |
CSS: | |
.container { | |
display: table-cell; | |
vertical-align: middle; | |
height: 444px; width: 333px; border: 1px solid red; /* просто чтобы было видно ;) */ | |
} | |
*+html .auxiliary { | |
display: inline-block; | |
vertical-align: middle; | |
width: 0px; | |
height: 100%; | |
} | |
*+html .container div { | |
display: inline-block; | |
vertical-align: middle; | |
} | |
*+html .container div, .auxiliary { | |
display: inline; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment