CSS box-shadow hidden (z-index does not fix)

Tophers picture Tophers · Mar 31, 2011 · Viewed 36.3k times · Source

I have a box-shadow on my #primaryNav div. Unfortunately, the shadow is being covered/hidden by the background of the following #page element.

I tried to set a z-index of 100 to #primaryNav and a z-index of -100 to #page, but that does not fix my problem.

Any ideas what I'm doing wrong?

Answer

biggles picture biggles · Mar 31, 2011

You need to define positioning for #primaryNav. Z-index only affects positioned elements. I just added this in firebug and it fixed:

#primaryNav {
  position: relative;
 }

I would avoid using a negative z-index. Simply change z-index of #page to 0.