V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Can I use?
http://caniuse.com/
Less
http://lesscss.org
Cool Libraries
Bootstrap from Twitter
Jetstrap
wdssmq
V2EX  ›  CSS

行内元素的 padding 表现问题

  •  
  •   wdssmq ·
    wdssmq · 210 天前 · 718 次点击
    这是一个创建于 210 天前的主题,其中的信息可能已经有所发展或是发生改变。

    为什么这个 span 的上一行被遮挡,而下一行没有? [ css 吧] _百度贴吧 https://tieba.baidu.com/p/8625827524

    贴吧看到的,下边是我的回复:

    实际表现上像是第 n + 1 行比第 n 行有更高的 z-index 值,然而不改定位时单独指定 z-index 又是无效的,,AI 也没给出对题的解释。。

    p 中有一个 span ,为 span 设置 padding 和 背景色,span 显示在第二行,为什么第一行会被 span 遮挡而第三行不会?

    2 条回复    2024-01-09 06:41:45 +08:00
    rabbbit
        1
    rabbbit  
       210 天前
    https://www.w3.org/TR/css-inline-3/#paint-order
    Except as specified for positioned boxes (see [CSS-POSITION-3]) inline-level boxes are painted in document order; the z-index property does not generally apply.

    加个属性 margin: 0 -20px; 就懂了
    chnwillliu
        2
    chnwillliu  
       109 天前 via Android
    Normal flow 的情况下由 line-height 不足或负 margin 导致的重叠,按文档流谁在后谁显示在上面。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2529 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 15:43 · PVG 23:43 · LAX 08:43 · JFK 11:43
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.