Line-height, which is frequently seen in tutorials at www.bkjia.com, contains many little-known things. The line-height value can be: <length >|< percentage >|< number> | noromal | inherit. Both em, px, and percentage are calculated relative to the font-size value of the element. However, when a block-level element inherits the line-height attribute of another element, the situation becomes more complex. When the line-height value is inherited from the parent element, it must be calculated from the parent element rather than the child element.
Reference content is as follows: <Body style = "font-size: 10px;"> <Div style = "line-height: 150%"> <P style = "font-size: 15px;"> gfire is a global provider of Chinese Internet information and tutorials. It has been insisting on providing impetus for Internet development for many years, liehuo is passionate, positive, upward, and progressive. the character advocated by Net! </P> </Div> </Body>
|
Here, the font-size of p is 16px, but the line-height inherited by p is only 15px, so the row gets closer. Solution: 1. You can explicitly set the line-height attribute for each element, but it is not practical.
2. specify a number to set the scaling factor.
Reference content is as follows: <Body style = "font-size: 10px;"> <Div style = "line-height: 1.5"> <P style = "font-size: 15px;"> gfire is a global provider of Chinese Internet information and tutorials. It has been insisting on providing impetus for Internet development for many years, liehuo is passionate, positive, upward, and progressive. the character advocated by Net! </P> </Div> </Body> |
When a number is specified, the zoom factor inherits the value instead of the calculated value. This number applies to this element and all its child elements, so each element can calculate line-height based on its own font-size value. So the line-height of p here is 15 * 1.5px;