• 请不要在回答技术问题时复制粘贴 AI 生成的内容
pinews
V2EX  ›  程序员

chrome 用 font-weight 上遇到一个怪问题,是怎么回事?

  •  
  •   pinews · Oct 28, 2019 · 1779 views
    This topic created in 2387 days ago, the information mentioned may be changed or developed.
    firefox 也有这个问题,就是子元素的高度与撑开的父元素高度不一致
    大家可以看演示代码,https://jsbin.com/cehebobusu/edit?html,output。
    用上 font-weight:300 后,a 高度 20,body 元素 22 或 21.5,去掉之后都为 21。
    这个是 bug 还是怎滴,我的网站因为这个多了一条白线。
    2 replies    2019-10-29 04:33:45 +08:00
    eason1874
        1
    eason1874  
       Oct 28, 2019
    内联元素高度一向很迷,具体机制我不懂,严格要求高宽度对齐的元素我都是用块级,a 标签也来个 display:block,简单粗暴解决战斗。
    pinews
        2
    pinews  
    OP
       Oct 29, 2019
    @eason1874 找到原因了 微软雅黑和微软雅黑 light 行高不一样,子元素是 light 的高度,父元素确实正常字体的高度,
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5721 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 45ms · UTC 06:00 · PVG 14:00 · LAX 23:00 · JFK 02:00
    ♥ Do have faith in what you're doing.