I can not understand how the method of vertical centering.
.parent { height:100px; width:600px; border:1px solid #ff0000; } .helper { display:inline-block; height:100%; width:1px; background:green; } .child { display:inline-block; vertical-align:middle; border:1px solid #0000ff; }
<div class="parent"> <div class="helper"></div> <div class="child">TEXT</div> </div>
If you give the .helper element vertical-align: middle, it is centered perfectly. Without it, no. But it must be without it?
The height of the line is given by the .helper block in 100% of the parent. Further, the following is known - vertical-align: middle - alignment of the midpoint of the element at the baseline of the parent plus half the height of the parent element. The baseline is at the bottom .helper + half the height of the parent element. Following this, the .child element should now be centered, but in reality it simply matched its midpoint to the baseline. Please explain what I do not understand ??