Z-Index Relative or Absolute?

前端 未结 4 678
野性不改
野性不改 2020-11-27 02:30

I\'m trying to find an answer to the following question:

Is an element\'s z-index style its absolute stack order, or its stack order relative to its parent?

4条回答
  •  Happy的楠姐
    2020-11-27 03:06

    Here is the W3C specification for z-index.

    I think the most important line, based on your question is the following:

    The order in which the rendering tree is painted onto the canvas is described in terms of stacking contexts. Stacking contexts can contain further stacking contexts. A stacking context is atomic from the point of view of its parent stacking context; boxes in other stacking contexts may not come between any of its boxes.

    This seems to indicate that nothing can be drawn in between the div with z-index: -100 and the div with z-index: 200.

提交回复
热议问题