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

行内元素的 padding 表现问题

  •  
  •   wdssmq ·
    wdssmq · Sep 30, 2023 · 2247 views
    This topic created in 952 days ago, the information mentioned may be changed or developed.

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

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

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

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

    2 replies    2024-01-09 06:41:45 +08:00
    rabbbit
        1
    rabbbit  
       Sep 30, 2023
    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  
       Jan 9, 2024 via Android
    Normal flow 的情况下由 line-height 不足或负 margin 导致的重叠,按文档流谁在后谁显示在上面。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3038 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 61ms · UTC 13:35 · PVG 21:35 · LAX 06:35 · JFK 09:35
    ♥ Do have faith in what you're doing.