templates/common/_gallery.html.twig line 1
<style>
.swiper {
width: 100%;
height: 800px;
}
.swiper-slide {
text-align: center;
font-size: 18px;
background-color: #2b2b2b;
display: flex;
justify-content: center;
align-items: center;
}
.swiper-slide img {
display: block;
width: 100%;
height: 100%;
object-fit: cover;
}
.swiper-button-next:after,
.swiper-button-prev:after{
font-size: 16px;
background-color: rgba(255,255,255,.5);
padding: 20px;
font-weight: bold;
}
</style>
<div class="swiper mySwiper">
<div class="swiper-wrapper">
{% for img in images %}
<div class="swiper-slide"
style="background-image: url({{ asset(img.filename) }}); background-size: contain; background-repeat: no-repeat;background-position: center center;"></div>
{% endfor %}
</div>
<div class="swiper-button-next"></div>
<div class="swiper-button-prev"></div>
<div class="swiper-pagination"></div>
</div>
<!-- Initialize Swiper -->
<script>
var swiper = new Swiper(".mySwiper", {
slidesPerView: 1,
keyboard: {
enabled: true,
},
pagination: {
el: ".swiper-pagination",
clickable: true,
},
navigation: {
nextEl: ".swiper-button-next",
prevEl: ".swiper-button-prev",
},
autoplay: {
delay: 5000,
},
});
</script>