V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
mathcoder23
V2EX  ›  PHP

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

  •  
  •   mathcoder23 · Oct 26, 2016 · 10219 views
    This topic created in 3471 days ago, the information mentioned may be changed or developed.
    7 replies    2016-10-27 09:26:54 +08:00
    mathcoder23
        1
    mathcoder23  
    OP
       Oct 26, 2016
    % 基于当前字体尺寸的百分比行间距。
    yjxjn
        2
    yjxjn  
       Oct 26, 2016
    当前字体尺寸。
    yjxjn
        3
    yjxjn  
       Oct 26, 2016   ❤️ 1
    没打完就出去了。。。。
    具体在这里:
    % 基于当前字体尺寸的百分比行间距。
    http://www.w3school.com.cn/cssref/pr_dim_line-height.asp
    baiyun888
        4
    baiyun888  
       Oct 26, 2016   ❤️ 1
    从来没用过 line-height 的 100%
    otakustay
        5
    otakustay  
       Oct 26, 2016   ❤️ 1
    <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
        6
    ianva  
       Oct 26, 2016   ❤️ 1
    尽量用 1 ,而不是 100%,因为设定 line-height 会影响到设定元素的子元素, 100%是根据父元素字体计算出尺寸子元素继承,而 1 是根据子元素字体计算出尺寸子元素继承,所以根据百分比设定的时候很有可能得不到自己真正想要的尺寸
    mathcoder23
        7
    mathcoder23  
    OP
       Oct 27, 2016
    @ianva 我其实想设置不定高度的垂直居中...最后还是通过计算等到高度给 line-height 设置固定的值
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3519 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 11:45 · PVG 19:45 · LAX 04:45 · JFK 07:45
    ♥ Do have faith in what you're doing.