📄 visudet.html
字号:
href="visuren.html#inline-formatting">inline formatting contexts</a>,user agents flow inline boxes into a vertical stack of <ahref="visuren.html#line-box">line boxes</a>. The height of a line boxis determined as follows:</p><ol><li>The height of each inline box in the line box is calculated (see<a href="#Computing_heights_and_margins">"Computing heights andmargins"</a> and the <a href="visudet.html#propdef-line-height" class="noxref"><spanclass="propinst-line-height">'line-height'</span></a> property).<li>The inline boxes are aligned vertically accordingto their <a href="visudet.html#propdef-vertical-align" class="noxref"><span class="propinst-vertical-align">'vertical-align'</span></a>property. <li>The line box height is the distance between the uppermostbox top and the lowermost box bottom.</ol><p>Empty inline elements generate empty inline boxes, but these boxesstill have margins, padding, borders and a line height, and thusinfluence these calculations just like elements with content.<P>Note that if all the boxes in the line box are aligned along theirbottoms, the line box will be exactly the height of the tallest box.If, however, the boxes are aligned along a common baseline, the linebox top and bottom may not touch the top and bottom of the tallestbox.<H3><a name="q22">10.8.1 Leading and half-leading</a></h3><P>Since the height of an inline box may be different from the font sizeof text in the box (e.g., <a href="visudet.html#propdef-line-height" class="noxref"><spanclass="propinst-line-height">'line-height'</span></a> > 1em), there maybe space above and below rendered glyphs. The difference between thefont size and the computed value of <a href="visudet.html#propdef-line-height" class="noxref"><spanclass="propinst-line-height">'line-height'</span></a> is called the <a name="x15"><spanclass="index-def" title="leading"><EM>leading</EM></span></a>. Half theleading is called the <a name="x16"><span class="index-def"title="half-leading"><EM>half-leading</EM></span></a>.<P>User agents center glyphs vertically in an inline box, addinghalf-leading on the top and bottom. For example, if a piece of textis '12pt' high and the <a href="visudet.html#propdef-line-height" class="noxref"><spanclass="propinst-line-height">'line-height'</span></a> value is '14pt',2pts of extra space should be added: 1pt above and 1pt below theletters. (This applies to empty boxes as well, as if the empty boxcontained an infinitely narrow letter.)<P>When the <a href="visudet.html#propdef-line-height" class="noxref"><span class="propinst-line-height">'line-height'</span></a>value is less than the font size, the final inline box height will beless than the font size and the rendered glyphs will "bleed" outsidethe box. If such a box touches the edge of a line box, the renderedglyphs will also "bleed" into the adjacent line box.<P>Although margins, borders, and padding of non-replaced elements donot enter into inlinebox height calculation (and thus the line box calculation), they arestill rendered around inline boxes. This means that if the height of a line box is shorterthan the <a href="box.html#outer-edge">outer edges</a> of the boxes itcontains, backgrounds and colors of padding and borders may "bleed"into adjacent line boxes. However, in this case, some user agents mayuse the line box to "clip" the border and padding areas (i.e., notrender them).<div class="propdef"><dl><dt><span class="index-def" title="'line-height'"><a name="propdef-line-height" class="propdef-title"><strong>'line-height'</strong></a></span><dd><table class="propinfo" cellspacing=0 cellpadding=0><tr valign=baseline><td><em>Value:</em> <td>normal | <a href="syndata.html#value-def-number" class="noxref"><span class="value-inst-number"><number></span></a> | <a href="syndata.html#value-def-length" class="noxref"><span class="value-inst-length"><length></span></a> | <a href="syndata.html#value-def-percentage" class="noxref"><span class="value-inst-percentage"><percentage></span></a> | <a href="cascade.html#value-def-inherit" class="noxref"><span class="value-inst-inherit">inherit</span></a><tr valign=baseline><td><em>Initial:</em> <td>normal<tr valign=baseline><td><em>Applies to:</em> <td>all elements<tr valign=baseline><td><em>Inherited:</em> <td>yes<tr valign=baseline><td><em>Percentages:</em> <td>refer to the font size of the element itself<tr valign=baseline><td><em>Media:</em> <td><a href="media.html#visual-media-group" class="noxref">visual</a></table></dl></div><p>If the property is set on a <ahref="visuren.html#block-level">block-level</a> element whose contentis composed of <a href="visuren.html#inline-level">inline-level</a>elements, it specifies the <em>minimal</em> height of each generated inline box.<p>If the property is set on an <ahref="visuren.html#inline-level">inline-level</a> element, itspecifies the <em>exact</em> height of each box generated by theelement. (Except for inline <ahref="conform.html#replaced-element">replaced</a> elements, where theheight of the box is given by the <a href="visudet.html#propdef-height" class="noxref"><spanclass="propinst-height">'height'</span></a> property.)<P>Values for this property have the following meanings:</p><dl><dt><strong>normal</strong><dd>Tells user agents to set the <ahref="cascade.html#computed-value">computed value</a> to a "reasonable"value based on the font size of the element. Thevalue has the same meaning as <span class="index-inst" title="<number>"><a name="x18" href="syndata.html#value-def-number" class="noxref"><span class="value-inst-number"><number></span></a></span>.We recommend a computed value for 'normal' between 1.0 to 1.2. <dt><span class="index-inst" title="<length>"><a name="x19" href="syndata.html#value-def-length" class="noxref"><spanclass="value-inst-length"><strong><length></strong></span></a></span><dd>The box height is set to this length. Negative values are illegal.<dt><span class="index-inst" title="<number>"><a name="x20" href="syndata.html#value-def-number" class="noxref"><spanclass="value-inst-number"><strong><number></strong></span></a></span><dd>The<a href="cascade.html#computed-value">computed value</a> of the property is this number multiplied by theelement's font size. Negative values are illegal. However, thenumber, not the <a href="cascade.html#computed-value">computed value</a>,is inherited.<dt><span class="index-inst" title="<percentage>"><a name="x21" href="syndata.html#value-def-percentage" class="noxref"><spanclass="value-inst-percentage"><strong><percentage></strong></span></a></span><dd>The <a href="cascade.html#computed-value">computed value</a> of theproperty is this percentage multiplied by the element's computed font size. Negative values are illegal.</dl><div class="example"><P style="display:none">Example(s):</P><P>The three rules in the example below have the same resultant line height:<PRE>DIV { line-height: 1.2; font-size: 10pt } /* number */DIV { line-height: 1.2em; font-size: 10pt } /* length */DIV { line-height: 120%; font-size: 10pt } /* percentage */</PRE></div><P>When an element contains text that is rendered in more than onefont, user agents should determine the <a href="visudet.html#propdef-line-height" class="noxref"><spanclass="propinst-line-height">'line-height'</span></a> value according tothe largest font size. <P>Generally, when there is only one value of <a href="visudet.html#propdef-line-height" class="noxref"><spanclass="propinst-line-height">'line-height'</span></a> for all inlineboxes in a paragraph (and no tall images), the above will ensure thatbaselines of successive lines are exactly <a href="visudet.html#propdef-line-height" class="noxref"><spanclass="propinst-line-height">'line-height'</span></a> apart. This isimportant when columns of text in different fonts have to be aligned,for example in a table.<P>Note that replaced elements have a <a href="fonts.html#propdef-font-size" class="noxref"><spanclass="propinst-font-size">'font-size'</span></a> and a <a href="visudet.html#propdef-line-height" class="noxref"><spanclass="propinst-line-height">'line-height'</span></a> property, even ifthey are not used directly to determine the height of the box. The<a href="fonts.html#propdef-font-size" class="noxref"><span class="propinst-font-size">'font-size'</span></a> is, however, usedto define the 'em' and 'ex' units, and the 'line-height' has a role inthe <a href="visudet.html#propdef-vertical-align" class="noxref"><span class="propinst-vertical-align">'vertical-align'</span></a>property.<div class="propdef"><dl><dt><span class="index-def" title="'vertical-align'"><a name="propdef-vertical-align" class="propdef-title"><strong>'vertical-align'</strong></a></span><dd><table class="propinfo" cellspacing=0 cellpadding=0><tr valign=baseline><td><em>Value:</em> <td>baseline | sub | super | top | text-top | middle | bottom | text-bottom | <a href="syndata.html#value-def-percentage" class="noxref"><span class="value-inst-percentage"><percentage></span></a> | <a href="syndata.html#value-def-length" class="noxref"><span class="value-inst-length"><length></span></a> | <a href="cascade.html#value-def-inherit" class="noxref"><span class="value-inst-inherit">inherit</span></a><tr valign=baseline><td><em>Initial:</em> <td>baseline<tr valign=baseline><td><em>Applies to:</em> <td>inline-level and 'table-cell' elements<tr valign=baseline><td><em>Inherited:</em> <td>no<tr valign=baseline><td><em>Percentages:</em> <td>refer to the 'line-height' of the element itself<tr valign=baseline><td><em>Media:</em> <td><a href="media.html#visual-media-group" class="noxref">visual</a></table></dl></div><P>This property affects the vertical positioning inside a line box ofthe boxes generated by an inline-level element. The following valuesonly have meaning with respect to a parent inline-level element, or toa parent block-level element, if that element generates <ahref="visuren.html#anonymous">anonymous inline boxes</a>; they have noeffect if no such parent exists.</P> <div class="note"><P><em><strong>Note.</strong> Values of this property haveslightly different meanings in the context of tables.Please consult the section on <a href="tables.html#height-layout">table height algorithms</a> for details.</em></div><DL> <DT><strong>baseline</strong> <DD>Align the baseline of the box with the baseline of the parent box. If the box doesn't have a baseline, align the bottom of the box with the parent's baseline. <DT><strong>middle</strong> <DD>Align the vertical midpoint of the box with the baseline of the parent box plus half the x-height of the parent. <DT><strong>sub</strong> <DD>Lower the baseline of the box to the proper position for subscripts of the parent's box. (This value has no effect on the font size of the element's text.) <DT><strong>super</strong> <DD>Raise the baseline of the box to the proper position for superscripts of the parent's box. (This value has no effect on the font size of the element's text.) <DT><strong>text-top</strong> <DD>Align the top of the box with the top of the parent element's font. <DT><strong>text-bottom</strong> <DD>Align the bottom of the box with the bottom of the parent element's font. <DT><span class="index-inst" title="<percentage>"><a name="x23" href="syndata.html#value-def-percentage" class="noxref"><span class="value-inst-percentage"><strong><percentage> </strong></span></a></span> <DD>Raise (positive value) or lower (negative value) the box by this distance (a percentage of the <a href="visudet.html#propdef-line-height" class="noxref"><span class="propinst-line-height">'line-height'</span></a> value). The value '0%' means the same as 'baseline'. <DT><span class="index-inst" title="<length>"><a name="x24" href="syndata.html#value-def-length" class="noxref"><span class="value-inst-length"><strong>&
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -