css - inline elements ignoring line-height

后端 未结 1 624
感情败类
感情败类 2020-11-30 10:33

I\'m having trouble figuring out why inline elements ignore line-height in some browsers (Chrome and Firefox ignore it, but IE9 does not).

Here is an e

相关标签:
1条回答
  • 2020-11-30 11:11

    What webkit inspector shows (and what you measured in PhotoShop) is the content area's dimensions.

    See http://www.w3.org/TR/CSS2/visudet.html#inline-non-replaced

    The height of the content area [of inline elements] should be based on the font, but this specification does not specify how. A UA may, e.g., use the em-box or the maximum ascender and descender of the font...

    Different browsers simply use a different approach here. See http://jsfiddle.net/ejqTD/1/ for an illustration of that. Note how webkit renders a higher content area, but line-height is still correct.

    The content area exceeds the line box in this case, which is permitted: http://www.w3.org/TR/CSS2/visudet.html#leading

    if the height specified by 'line-height' is less than the content height of contained boxes, backgrounds and colors of padding and borders may "bleed" into adjoining line boxes.

    It's easy to see if you consider line-heights < 1: http://jsfiddle.net/KKMmK/

    0 讨论(0)
提交回复
热议问题