The Vertical-align and line-height in CSS

Source: Internet
Author: User

Line-height is defined as the distance between the two baselines, that is, the height of a row (literally, the row height), and the value of Vertical-align, Top,middle,baseline,bottom, as the name implies is the line alignment, midline alignment, Baseline alignment, Bottom line alignment (a bit different from the English one), enter an X, the bottom of which is the baseline, and the middle is the midline. (Midline is not the vertical center, but the center of X, using vertical-align:middle alignment, the surface is vertical horizontal alignment, there will actually be a pixel-level gap, you can set the font-size to 0, so that the various lines are coincident, in the vertical center of the place)

For the Inline-block element, when there is no inline box in the normal flow of the row box, and its overflow is set to visible, margin is used as the baseline, if aligned with the default Vertical-align:baseline, will be aligned with margin. This alignment produces the effect of self-test corresponding to the meaning of vertical-align can be deduced, not to repeat.

For the various effects produced by Line-height,vertical-align, understand its original meaning, it is not difficult to understand the effect of the next, write down the vertical-align:text-top and text-bottom usage.

Vertical-align:middle and so on, alignment depends on the line is in the sibling element, with uncertainty (but can also be based on this feature to create the effect of the upper and lower block offset), and Text-top, Bottom are aligned according to the font-size of the parent element to determine the position of the various lines.

Not to be continued ...

The Vertical-align and line-height in CSS

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.