I was trying to vertically align an h1
tag that is on top of a picture.
I used position:relative
, and top:50%
and I don't understand why it didn't vertically aligned it even though I used top:50%
.
So this time I added transform: translateY(-50%);
and for some reason it is now vertically aligned.
Can somebody please explain to me what translateY(-50%)
does?