V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
mathcoder23
V2EX  ›  PHP

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

  •  
  •   mathcoder23 · 2016-10-26 10:19:05 +08:00 · 9281 次点击
    这是一个创建于 2710 天前的主题,其中的信息可能已经有所发展或是发生改变。
    7 条回复    2016-10-27 09:26:54 +08:00
    mathcoder23
        1
    mathcoder23  
    OP
       2016-10-26 10:22:25 +08:00
    % 基于当前字体尺寸的百分比行间距。
    yjxjn
        2
    yjxjn  
       2016-10-26 10:32:05 +08:00
    当前字体尺寸。
    yjxjn
        3
    yjxjn  
       2016-10-26 10:33:09 +08:00   ❤️ 1
    没打完就出去了。。。。
    具体在这里:
    % 基于当前字体尺寸的百分比行间距。
    http://www.w3school.com.cn/cssref/pr_dim_line-height.asp
    baiyun888
        4
    baiyun888  
       2016-10-26 11:03:26 +08:00   ❤️ 1
    从来没用过 line-height 的 100%
    otakustay
        5
    otakustay  
       2016-10-26 11:33:04 +08:00   ❤️ 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  
       2016-10-26 12:54:48 +08:00   ❤️ 1
    尽量用 1 ,而不是 100%,因为设定 line-height 会影响到设定元素的子元素, 100%是根据父元素字体计算出尺寸子元素继承,而 1 是根据子元素字体计算出尺寸子元素继承,所以根据百分比设定的时候很有可能得不到自己真正想要的尺寸
    mathcoder23
        7
    mathcoder23  
    OP
       2016-10-27 09:26:54 +08:00
    @ianva 我其实想设置不定高度的垂直居中...最后还是通过计算等到高度给 line-height 设置固定的值
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1446 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 17:25 · PVG 01:25 · LAX 10:25 · JFK 13:25
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.