templates/common/_gallery.html.twig line 1

  1. <style>
  2.     .swiper {
  3.         width: 100%;
  4.         height: 800px;
  5.     }
  6.     .swiper-slide {
  7.         text-align: center;
  8.         font-size: 18px;
  9.         background-color: #2b2b2b;
  10.         display: flex;
  11.         justify-content: center;
  12.         align-items: center;
  13.     }
  14.     .swiper-slide img {
  15.         display: block;
  16.         width: 100%;
  17.         height: 100%;
  18.         object-fit: cover;
  19.     }
  20.     .swiper-button-next:after,
  21.     .swiper-button-prev:after{
  22.         font-size: 16px;
  23.         background-color: rgba(255,255,255,.5);
  24.         padding: 20px;
  25.         font-weight: bold;
  26.     }
  27. </style>
  28. <div class="swiper mySwiper">
  29.     <div class="swiper-wrapper">
  30.         {% for img in images %}
  31.             <div class="swiper-slide"
  32.                  style="background-image: url({{ asset(img.filename) }}); background-size: contain; background-repeat: no-repeat;background-position: center center;"></div>
  33.         {% endfor %}
  34.     </div>
  35.     <div class="swiper-button-next"></div>
  36.     <div class="swiper-button-prev"></div>
  37.     <div class="swiper-pagination"></div>
  38. </div>
  39. <!-- Initialize Swiper -->
  40. <script>
  41.     var swiper = new Swiper(".mySwiper", {
  42.         slidesPerView: 1,
  43.         keyboard: {
  44.             enabled: true,
  45.         },
  46.         pagination: {
  47.             el: ".swiper-pagination",
  48.             clickable: true,
  49.         },
  50.         navigation: {
  51.             nextEl: ".swiper-button-next",
  52.             prevEl: ".swiper-button-prev",
  53.         },
  54.         autoplay: {
  55.             delay: 5000,
  56.         },
  57.     });
  58. </script>