-1

I am working on a website and at this problem I got stuck I have created a navigation bar and applied fixed position property in css, but below it, I have created an hover element but this hover display above the navigation bar. Here are some screenshots:)

Here it is not creating any problem(before scrolling down)

after scrolling down it is displaying on the navigation bar

  • Does this answer your question? [All About.... Z-Index?](https://stackoverflow.com/questions/2305669/all-about-z-index) – Christian Sep 01 '22 at 18:44

3 Answers3

1

Maybe this works:

nav {
    position: sticky;
    top: 0;
    z-index: 40;
}
Sven
  • 66
  • 2
0

Set the z-index of the navigation bar large enough to always be larger than the hovering element, even when it's hovering.

0

Make the z-index of the navigation greater than the z-index of the hover element in css.

nav { 
  z-index: 2
}

hoverElement {
  z-index: -1 
}