Why does z-index not work?

前端 未结 5 1497
无人共我
无人共我 2020-11-21 05:39

So if I understand z-index correctly, it would be perfect in this situation:

\"enter

5条回答
  •  醉酒成梦
    2020-11-21 05:57

    The z-index property only works on elements with a position value other than static (e.g. position: absolute;, position: relative;, or position: fixed).

    There is also position: sticky; that is supported in Firefox, is prefixed in Safari, worked for a time in older versions of Chrome under a custom flag, and is under consideration by Microsoft to add to their Edge browser.

    Important
    For regular positioning, be sure to include position: relative on the elements where you also set the z-index. Otherwise, it won't take effect.

提交回复
热议问题