solvit.io

Center the text and contents of a <div> vertically

Solution #1
div {
    align-content: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
Solution #2

If you need to support legacy browsers (prior to Internet Explorer 10):

div {
    position: relative;
    text-align: center;
    top: 50%;
    -ms-transform: translateY(-50%);
    -webkit-transform: translateY(-50%);
    transform: translateY(-50%);
}
Find more solutions about: ,