I am using vue-awesome-swiper https://madewithvuejs.com/vue-awesome-swiper in a Vue + LAravel project.
This is the result I am trying to achieve. The swiper arrows are on top and are clickable.
Instead, what I am achieving is this. The swiper arrows are not on the top and are not clickable.
For the vue-awesome-swiper to work the code has to follow an specific format.
This is the swiper code I am using:
<div class="container-fluid p-0 cd-contentx">
<div class="row mx-0 position-relative">
<swiper class="swiper position-relative" :options="swiperOptionAuto">
<swiper-slide class="col-border" style="width: auto">
<img src="/images/homepage/ambientes/ambience-1.jpg" alt="" class="img-fluid-ambientes">
</swiper-slide>
<swiper-slide class="col-border" style="width: auto">
<img src="/images/homepage/ambientes/ambience-1.jpg" alt="" class="img-fluid-ambientes">
</swiper-slide>
<swiper-slide class="col-border" style="width: auto">
<img src="/images/homepage/ambientes/ambience-1.jpg" alt="" class="img-fluid-ambientes">
</swiper-slide>
<swiper-slide class="col-border" style="width: auto">
<img src="/images/homepage/ambientes/ambience-1.jpg" alt="" class="img-fluid-ambientes">
</swiper-slide>
<swiper-slide class="col-border" style="width: auto">
<img src="/images/homepage/ambientes/ambience-1.jpg" alt="" class="img-fluid-ambientes">
</swiper-slide>
<div class="swiper-btn-prev swiper-light" slot="button-prev"></div>
<div class="swiper-btn-next swiper-light" slot="button-next"></div>
</swiper>
<div class="col-12 text-center swiper-caption">
<h4 class="title-swiper-caption">Exquisite Inspirations Room by Room</h4>
<a>EXPLORE ALL ROOMS</a>
</div>
</div>
</div>
This is the script of the swiper:
<script>
import { Swiper, SwiperSlide } from 'vue-awesome-swiper'
import "swiper/css/swiper.css"
export default {
name: 'swiper-example-navigation',
title: 'Navigation',
components: {
Swiper,
SwiperSlide
},
data() {
return {
swiperOptionAuto: {
slidesPerView: 'auto',
loop: true,
centeredSlides: true,
navigation: {
nextEl: '.swiper-btn-next',
prevEl: '.swiper-btn-prev'
}
}
}
}
}
</script>
And these are the styles:
.swiper-btn-next, .swiper-btn-prev {
top: 93%;
position: absolute;
z-index: 1000;
cursor: pointer;
padding: 6px;
}
.swiper-caption {
z-index: 1;
background-color: #32151a;
opacity: 70%;
margin-bottom: 3px;
padding: 2rem;
position:absolute;
bottom:0;
right:0;
}
As you can see, the z-index of the swiper buttons is higher, but they are not on top of the .swiper-caption div. I tried changing the structure of the html code to make the swiper buttons and swiper caption to be in the same div, like so:
<div class="container-fluid p-0 cd-contentx">
<div class="row mx-0 position-relative">
<swiper class="swiper position-relative" :options="swiperOptionAuto">
<swiper-slide class="col-border" style="width: auto">
<img src="/images/homepage/ambientes/ambience-1.jpg" alt="" class="img-fluid-ambientes">
</swiper-slide>
<swiper-slide class="col-border" style="width: auto">
<img src="/images/homepage/ambientes/ambience-1.jpg" alt="" class="img-fluid-ambientes">
</swiper-slide>
<swiper-slide class="col-border" style="width: auto">
<img src="/images/homepage/ambientes/ambience-1.jpg" alt="" class="img-fluid-ambientes">
</swiper-slide>
<swiper-slide class="col-border" style="width: auto">
<img src="/images/homepage/ambientes/ambience-1.jpg" alt="" class="img-fluid-ambientes">
</swiper-slide>
<swiper-slide class="col-border" style="width: auto">
<img src="/images/homepage/ambientes/ambience-1.jpg" alt="" class="img-fluid-ambientes">
</swiper-slide>
<div class="col-12 text-center swiper-caption">
<h4 class="title-swiper-caption">Exquisite Inspirations Room by Room</h4>
<a>EXPLORE ALL ROOMS</a>
<div class="swiper-btn-prev swiper-light" slot="button-prev"></div>
<div class="swiper-btn-next swiper-light" slot="button-next"></div>
</div>
</swiper>
</div>
</div>
But the result I get when I use the code above is this. The swiper buttons and the swiper caption disappear, probably because in the vue-awesome-swiper structure, the swiper buttons can't be be inside another div. I am not sure why.
Any suggestions on how to achieve the correct result?