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

行内元素的 padding 表现问题

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

    腾讯云最新优惠活动来了:云产品限时1折,云服务器低至88元/年 ,点击这里立即抢购:9i0i.cn/qcloud,更有2860元代金券免费领取,付款直接抵现金用,点击这里立即领取:9i0i.cn/qcloudquan

    (福利推荐:你还在原价购买阿里云服务器?现在阿里云0.8折限时抢购活动来啦!4核8G企业云服务器仅2998元/3年,立即抢购>>>:9i0i.cn/aliyun

    为什么这个 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  
       217 天前
    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  
       116 天前 via Android
    Normal flow 的情况下由 line-height 不足或负 margin 导致的重叠,按文档流谁在后谁显示在上面。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   733 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 21:33 · PVG 05:33 · LAX 14:33 · JFK 17:33
    Developed with CodeLauncher
    ? Do have faith in what you're doing.


    http://www.vxiaotou.com