Vertical alignment

Vertical alignment using position:absolute top, bottom:0 and margin:auto

by Lucas Krause

HTML

<div class=a>hello</div>

CSS

html, body {
    height:100%;
}
body {
    position:relative;
    background-color:#eee;
    margin:0;
}
.a {
    position:absolute;
    background:tomato;
    top:0;
    left:0;
    right:0;
    bottom:0;
    margin:auto;
    width:100px;
    color:#fff;
    box-sizing:border-box;
    padding:10px;
    /**/height:100px;/**/
}