9 ms·
I do: .thing { position: relative; } .thing .child { width: 50px; height: 50px; position: absolute; top: 50%; m
by err4nt 13y ago
I do:
.thing {
position: relative;
}
.thing .child {
width: 50px;
height: 50px;
position: absolute;
top: 50%;
margin-top: -25px; /* half of height */
}
Or else if it's text I just make the line-height the same height as the parent element. That keeps things vertically centred :)