Vertical-align and line-height ),
Method 1: vertical-align
W3school definition: This attribute defines the vertical alignment of the baseline of an element in a row relative to the baseline of the row where the element is located
Best friend
Then Google. No definition is found on w3schools.
Only code can be written for testing
And then I understand it before I make such an explanation.
The object to which this attribute applies: the inline element (inline, inline-block also has the row attribute) and other table-cell
Common attribute values: top middle bottom
Personal Understanding
In my opinion, in general, the line that these letters spontaneously "sit" is the baseline. The distance between the two rows is line-height (the second method will be used later). It is unclear how to align the baseline after top middle bottom is set.
This is the result of testing top middle bottom.
Method 2: Use line-height
In the block element, set line-height to be the same as the height to vertically center the element in the row. Note that the most direct way to use the unit of the row height is to use px. If the percentage is used, for example, if 150% is used, 150% is calculated based on the font size of the parent element, and the child element still follows the calculated Row Height. If 1.5 is used, the row height is calculated by multiplying the font size of the child element by 1.5. In addition, 1.5em and so on are calculated according to the 150% case.
For more information about the two methods, see "I think ".
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.