.top-align {
vertical-align: top;
}
.center-align {
vertical-align: middle;
}
/*
For a flexed item you can you align - items to center content vertically
you can use justify content to center horizontally
*/
.container {
display: flex;
align-items: center;
justify-content: center;
}
.container{
display: table;
}
.div-inside-container{
display: table-cell;
vertical-align: middle;
}
margin-top: auto;
margin-bottom: auto;
<div style="display: table; height: 400px; overflow: hidden;">
<div style="display: table-cell; vertical-align: middle;">
<div>
everything is vertically centered in modern IE8+ and others.
</div>
</div>
</div>
. Please note that vertical-align only affects inline, inline-block, inline-table, and table cell elements.
<span class="align-baseline">baseline</span>
<span class="align-top">top</span>
<span class="align-middle">middle</span>
<span class="align-bottom">bottom</span>
<span class="align-text-top">text-top</span>
<span class="align-text-bottom">text-bottom</span>