Home  >  Article  >  Web Front-end  >  Detailed explanation of line and vertical-align examples in css

Detailed explanation of line and vertical-align examples in css

零下一度
零下一度Original
2017-06-24 11:57:111724browse

The formatting sequence of inline elements: font-size-->em box-->content area-->inline box-->place the inline box according to the baseline-->determine the height of the line box

Related concepts:
leading (line spacing): refers to the lead bar filled between two lines of text, equal to line-height and font The difference between -size, half of the leading is added above the text, and the other half of the leading is added below the text, only used for non-replaced elements.

emBox: The em box indicates the distance between baselines when there is no line spacing. The boundaries between characters are not specified. The actual glyph may be longer than its em box. Tall or shorter.

font-size Determines the height of the em box (em box) of a given font, but there is no guarantee that the actual displayed characters will be this size. The specific correspondence between the font-size attribute and the actual font size is determined by the font designer.

Baseline: The line upon which most letters "sit" and below which descenders extend is not the lower edge of the Chinese characters, but the lower edge of the English letter "x".

Content area (content area): Non-replacement elements are boxes composed of em boxes strung together, indirectly determined by font-size ;Replacement element: that is, the inherent height of the element plus possible margins and boxes.

Inline box (inline box): Virtual rectangular box, cannot be displayed, the size is the content area plus leading. For non-replaced elements, it is equal to the line-height value; for replaced elements, it is equal to the height of the content area. Several elements within the same line can have different line heights and inline box heights.

Line box (line box): The smallest box that contains the highest and lowest points of all inline boxes in the line, the line box The height is only related to the line height of the element in this line, and has no direct relationship with line-height, and has nothing to do with the height (height) of the parent element . Inline boxes are aligned vertically within the line based on the value of their vertical-align property.

Anonymous text: refers to all strings that are not contained in inline elements.

line-height: refers to the distance between the baselines of text lines, which determines how much each element box increases or decreases. The default is 1.2 times the font size of the element itself.

When the line-height value is inherited from the parent element, it inherits the value calculated on the parent element, not the value calculated on the child element (em, etc.). If it is a scaling factor (a pure numeric value without units), the scaling factor is inherited, not the calculated value. The product of the scaling factor and the font-size of the child element is eventually calculated.

Figure 1:

Figure 2: Line in css

Figure 3: OK Line box height

Replacement element
The margins and borders of the replacement element will affect the inline box of the element, which in turn affects the height of the line box .
Elements whose content is not controlled by the CSS visual formatting model, such as , ,