I came upon an example which allows vertical and horizontal centering of a div. See their jsFiddle.
I noticed that it only works if the html/body is set to display: table
and the width
and height
are set. Are there any downsides to setting the display on the entire html/body
to table
?
html, body {
width: 100%;
height: 100%;
display: table;
}