Brainstorm's snippets (1/247)

  CSS: How To Center an Object Exactly In The Center

.centered {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

To center text in a div, set line-height equal to height:

.center {
    height: 400px;
    line-height: 400px; /* same as height! */
}

References: