z-index not working with fixed positioning

后端 未结 8 1173
广开言路
广开言路 2020-11-22 03:46

I have a div with default positioning (i.e. position:static) and a div with a fixed position.

If I set the z-index

相关标签:
8条回答
  • 2020-11-22 04:39

    since your over div doesn't have a positioning, the z-index doesn't know where and how to position it (and with respect to what?). Just change your over div's position to relative, so there is no side effects on that div and then the under div will obey to your will.

    here is your example on jsfiddle: Fiddle

    edit: I see someone already mentioned this answer!

    0 讨论(0)
  • 2020-11-22 04:41

    When elements are positioned outside the normal flow, they can overlap other elements.

    according to Overlapping Elements section on http://web.archive.org/web/20130501103219/http://w3schools.com/css/css_positioning.asp

    0 讨论(0)
提交回复
热议问题