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

Z IndexCss

Z Index Problem Overview


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?

Z Index Solutions


Solution 1 - Z Index

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.

Solution 2 - Z Index

As jlego already said a relative position should fix it. By the way I would suggest ensuring that there is no shadow left or right of the #primaryNav. Since #primaryNav has a width of 100% a shadow on the side makes a horizontal scrollbar appear.

For fixing this you could set a overflow:hidden to #iframe

Solution 3 - Z Index

I took a look at your site and I think the border-bottom property of #primaryNav is covering up your shadow.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionTophersView Question on Stackoverflow
Solution 1 - Z IndexbigglesView Answer on Stackoverflow
Solution 2 - Z IndexKuepperView Answer on Stackoverflow
Solution 3 - Z IndexnjebertView Answer on Stackoverflow