Some of the understanding and techniques of line-height line Heights

Source: Internet
Author: User

As we all know, how to set the text vertical center, that is: set line-height and the height of the outer box is consistent;

In fact, there is a place, is superfluous, that is, height, set not set are centered;

So, is the height of the line high?

First small question: when the DIV does not set the height of the case, open its height is the text inside it?

The answer is no, you can try it when you set the line height to line-height:0; , the height of the div is still 0; it turns out that the height of the open div is related to the High Line of the text;

First understand, the inline box model, which has a line boxes, it is not to see the touch of things, it's work is wrapped in each row of text, its properties are only high height, first if the div is not set height, then its height is inside a line Boxes the height of an accumulation; (vertical many lines of text)

However, when there is only one row, line boxes will query which one of the rows is larger, and thus take its height, such as:<div> <span style= "line-height:20px;" > Take his men line-height<span style= "line-height:40px;" > Highest </span> value </span></div>, at this point line boxes row height is 40px, thus the height of the div is 40px; (horizontal line of text)

Next, add a magical magic, using the line-height and vertical attributes to achieve the vertical horizontal center of the multi-line picture

The parent wrapping layer is set, line-height and height are equal and text-align:center, the picture inside is set vertical-align:middle;

Some of the understanding and techniques of line-height line Heights

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.