Line-height measurement and use, line-height Measurement

Source: Internet
Author: User

Line-height measurement and use, line-height Measurement

1. line-height Definition

Line-height indicates the line height, that is, the distance between two lines of text baselines.

The following is an illustration:

The line height is the distance between two red lines, namely: 1 + 2 + 3 + 4

In actual measurement, the baseline is hard to find and can be measured.PIN to topTo replace the Row Height.

2. Line spacing

The difference between the calculated value of line-height and font-size (in CSS, it is "row spacing") is divided into two halves, respectively added to the top and bottom of a text line content.

Sample Code:

<! DOCTYPE html> 

Effect:

3. line-height

/* The default browser */line-height: normal;/* sets a number, which is multiplied by the current font size to set the line spacing */line-height: 100px; /* set a fixed row spacing */line-height: 1.8;/* set the row spacing based on the percentage of the current font size. */Line-height: 180%;

Note: line-height can be inherited,The descendant element inherits the zoom factor.Instead of calculating the value.

4. The image is not affected by line-height.

In this example, the image size is 150 * 150px.

Sample Code:

<! DOCTYPE html> 

Effect:

 

Note: there is a gap between the image and text,Because the alignment of img is baseline alignment by default.!

Change the baseline alignment of imgBottom alignmentThe following white space can be removed.

img{                vertical-align: bottom;            }

Effect:

 

In this case, line-height should be set to the Image height, that is, 150px.

The sample code for vertical center of text and image is as follows:

<! DOCTYPE html> 

Effect:

 

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.