The line height includes the content area and the blank area that is symmetrically expanded based on the content area; generally speaking, it can also be considered as the vertical distance between the baselines of adjacent text lines. In CSS, you can use the line-height attribute to set the line height; this attribute sets the distance (line height) between lines, and negative values are not allowed.
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
The line-height property affects the layout of the line box. When applied to a block-level element, it defines the minimum distance between baselines in that element rather than the maximum distance.
The calculated difference between line-height and font-size (known as "line spacing" in CSS) is divided into two halves and added to the top and bottom of a line of text content. The smallest box that can contain this content is a line box.
Example:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <style type="text/css"> p.small { line-height: 90% } p.big { line-height: 200% } </style> </head> <body> <p> 这是拥有标准What is line height in css的段落。 在大多数浏览器中默认What is line height in css大约是 110% 到 120%。 这是拥有标准What is line height in css的段落。 这是拥有标准What is line height in css的段落。 这是拥有标准What is line height in css的段落。 这是拥有标准What is line height in css的段落。 这是拥有标准What is line height in css的段落。 </p> <p class="small"> 这个段落拥有更小的What is line height in css。 这个段落拥有更小的What is line height in css。 这个段落拥有更小的What is line height in css。 这个段落拥有更小的What is line height in css。 这个段落拥有更小的What is line height in css。 这个段落拥有更小的What is line height in css。 这个段落拥有更小的What is line height in css。 </p> <p class="big"> 这个段落拥有更大的What is line height in css。 这个段落拥有更大的What is line height in css。 这个段落拥有更大的What is line height in css。 这个段落拥有更大的What is line height in css。 这个段落拥有更大的What is line height in css。 这个段落拥有更大的What is line height in css。 这个段落拥有更大的What is line height in css。 </p> </body> </html>
Rendering:
(Learning video sharing:
css video tutorialThe above is the detailed content of What is line height in css. For more information, please follow other related articles on the PHP Chinese website!