3 ms·
If you know the height of your centered box, it's not that hard. Create a wrapper div whose top is set 50% down the page but has a negative offset which is 50%
by mattwad 11y ago
If you know the height of your centered box, it's not that hard. Create a wrapper div whose top is set 50% down the page but has a negative offset which is 50% the height of the box:
.vertically-centered {
position: absolute
top: 50%;
height: 200px;
margin-top: -100px; /* minus half of `height` */
}
If you have trouble, try setting `height` to 100% on the <body> tag and any parents