How to fix z-index issue that does not work despite already having position & higher z-index value?

Viewed 79

I'm trying to implement z-index change on hover but it doesn't seem to work despite already using "position" on my elements.

This is what I was trying to do (the red navigation right or left side should go under the poster element on hover using z-index):

enter image description here

But this is what happen instead (z-index not working): enter image description here

$('.owl-carousel').owlCarousel({
  loop: true,
  margin: 10,
  stagePadding: 50,
  nav: true,
  dots: false,
  responsive: {
    0: {
      items: 1
    },
    600: {
      items: 3
    },
    1000: {
      items: 5
    }
  }
})
.owl-carousel {
  position: relative;
  width: 100%;
  margin-top: 65px;
}

.owl-carousel .owl-stage-outer {
  overflow: visible;
}

.owl-carousel .item {
  position: relative;
  height: 9%;
  width: auto;
  background: #4DC7A0;
  z-index: 0;
}

.owl-nav button {
  position: absolute;
  top: 0;
  height: 100%;
  width: 50px;
  z-index: 0;
  color: red;
  background: rgb(255 1 1 / 40%)!important;
  display: block;
  margin: 0!important;
}

.owl-nav button span {
  color: white!important;
  font-size: 51px;
}

.owl-nav .owl-next {
  right: 0;
  position: absolute;
  z-index: 0;
}

.owl-nav .owl-prev {
  left: 0;
  position: absolute;
  z-index: 0;
}

.owl-carousel .owl-item:hover {
  transform: scale(1.4);
  position: relative;
  z-index: 5;
}
<link rel="stylesheet" href="https://owlcarousel2.github.io/OwlCarousel2/assets/owlcarousel/assets/owl.carousel.min.css" />
<link rel="stylesheet" href="https://owlcarousel2.github.io/OwlCarousel2/assets/owlcarousel/assets/owl.theme.default.min.css" />
<link rel="stylesheet" href="https://owlcarousel2.github.io/OwlCarousel2/assets/css/docs.theme.min.css" />

<div class="owl-carousel owl-theme">
  <div class="item"><img src="https://i.imgur.com/iyp13K1.jpg"></div>
  <div class="item"><img src="https://i.imgur.com/iyp13K1.jpg"></div>
  <div class="item"><img src="https://i.imgur.com/iyp13K1.jpg"></div>
  <div class="item"><img src="https://i.imgur.com/iyp13K1.jpg"></div>
  <div class="item"><img src="https://i.imgur.com/iyp13K1.jpg"></div>
  <div class="item"><img src="https://i.imgur.com/iyp13K1.jpg"></div>
</div>

<script src="https://owlcarousel2.github.io/OwlCarousel2/assets/vendors/jquery.min.js"></script>
<script src="https://owlcarousel2.github.io/OwlCarousel2/assets/owlcarousel/owl.carousel.js"></script>

As you can see on the right side, despite already using position & z index on the poster element higher than the navigation element (the red ones), the poster element still sits underneath the navigation element.

How to fix this z-index issue?

0 Answers
Related