I have a login box on my page which I want to put in the middle of the page, so I used:
.login {
width: 280px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
}
And it worked. However, I'm not sure why. From my understanding, the top and left 50% puts the box left top corner in the middle, so the center of the box itself isn't in the center yet, but then after the transform translate line, it puts the box in the middle, how?
I thought that translate would just translate 50% x axis back and 50% y axis back to original position.