mathcoder23
V2EX  ›  PHP

css 中的 line-height 属性如果是 100%,这个百分比是谁的百分比

  •  
  •   mathcoder23 · Oct 26, 2016 · 10689 views
    This topic created in 3660 days ago, the information mentioned may be changed or developed.
    7 replies  •  2016-10-27 09:26:54 +08:00
    mathcoder23
    mathcoder23
    OP
    Oct 26, 2016
    1
    % 基于当前字体尺寸的百分比行间距。
    yjxjn
    yjxjn
    Oct 26, 2016
    2
    当前字体尺寸。
    yjxjn
    yjxjn
    Oct 26, 2016❤️1
    3
    没打完就出去了。。。。
    具体在这里:
    % 基于当前字体尺寸的百分比行间距。
    http://www.w3school.com.cn/cssref/pr_dim_line-height.asp
    baiyun888
    baiyun888
    Oct 26, 2016❤️1
    4
    从来没用过 line-height 的 100%
    otakustay
    otakustay
    Oct 26, 2016❤️1
    5
    <percentage>
    Relative to the font size of the element itself. The computed value is this percentage multiplied by the element's computed font size.
    Percentage and em values may have unexpected results, see "Notes" section.

    已经很清楚了
    ianva
    ianva
    Oct 26, 2016❤️1
    6
    尽量用 1 ,而不是 100%,因为设定 line-height 会影响到设定元素的子元素, 100%是根据父元素字体计算出尺寸子元素继承,而 1 是根据子元素字体计算出尺寸子元素继承,所以根据百分比设定的时候很有可能得不到自己真正想要的尺寸
    mathcoder23
    mathcoder23
    OP
    Oct 27, 2016
    7
    @ianva 我其实想设置不定高度的垂直居中...最后还是通过计算等到高度给 line-height 设置固定的值
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1602 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 51ms · UTC 23:11 · PVG 07:11 · LAX 15:11 · JFK 18:11
    ♥ Do have faith in what you're doing.