If you know the dimensions of div.
.centered {
position: fixed; /*IE6 position:absolute */
top: 50%;
left: 50%;
margin-top: -50px; /* Half of the Height of div*/
margin-left: -100px; /* Half of the Width of div*/
}
If you Don't know the dimensions of div.
.centered {
position: fixed; /*IE6 position:absolute */
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.centered {
position: fixed; /*IE6 position:absolute */
top: 50%;
left: 50%;
margin-top: -50px; /* Half of the Height of div*/
margin-left: -100px; /* Half of the Width of div*/
}
If you Don't know the dimensions of div.
.centered {
position: fixed; /*IE6 position:absolute */
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}