Center a div vertically & horizontally w/o fixed dimensions

by vincentpace

HTML

<div></div>

CSS

div {
    background-color: red;
    height: 20%;
    width: 20%;

    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}