I am trying to build a swiper slider with the following layout:
<div id="brokerCarousel" class="swiper">
<div class="swiper-container">
<div class="swiper-wrapper">
@foreach($partners as $partner)
<div class="swiper-slide">
<img src="{{ $partner->media('logo')->first() !== null ? $partner->media('logo')->first()->getUrl(800,600,'canvas') : '' }}" alt="{{ $partner->name }}">
</div>
@endforeach
</div>
</div>
</div>
I then have my JS code:
brokerCarousel() {
if (document.getElementById('brokerCarousel')) {
new Swiper('#brokerCarousel .swiper-container', {
slidesPerView: 10,
spaceBetween: 30,
autoplay: {
delay: 2500,
},
breakpoints: {
576: {
slidesPerView: 2,
},
768: {
slidesPerView: 3,
},
1200: {
slidesPerView: 5,
}
}
});
}
}
Where I set slides to 5.
My scss:
#brokerCarousel {
&.swiper{
width: 100%;
height: 100%;
.swiper-container {
max-height: 100%;
.swiper-wrapper {
.swiper-slide {
background-color: #fff;
padding: 30px;
border-radius: 10px;
img {
height: 200px;
width: auto;
}
}
}
}
}
}
But this is what my slides look like:
As you can see there are only two slides in view which is wrong by itself but they are also very wide. When I inspect the .swiper-slide
in my inspector I see this style is applied: width: 1600px; margin-right: 30px;
. My container is 1440px so one slide can never be 1600px when I have it set to 5.
What am I missing?