rcerrejon
2/11/2016 - 11:30 AM

Background absolute center horizontal and vertical

Background absolute center horizontal and vertical

/* CSS in order to center an element (with position absolute) in a container: */

.centeredIcon {
    background: url("http://www.google.com/favicon.ico") no-repeat transparent;
    width:64px;
    height:64px;
    position:absolute;
    left:50%;
    top:50%;
    margin-left:-32px; /* half of the width */
    margin-top:-32px; /* half of the height */
}