templates/front/_common/_marquee.html.twig line 1

Open in your IDE?
  1.   <style>
  2. :root {
  3.   --marquee-width: 100%;
  4.   --marquee-elements-displayed: {{ displayed.xs }};
  5.   --marquee-element-width: calc((var(--marquee-width) ) / var(--marquee-elements-displayed));
  6.   --marquee-animation-duration: calc(var(--marquee-elements) * {{ speed }}s);
  7. }
  8. .marquee {
  9.   width: var(--marquee-width);
  10.   color: #eee;
  11.   overflow: hidden;
  12.   position: relative;
  13. }
  14. .marquee-content {
  15.   margin: 0;
  16.   padding: 0;
  17.   list-style: none;
  18.   height: 100%;
  19.   display: flex;
  20.   animation: scrolling var(--marquee-animation-duration) linear infinite;
  21. }
  22.  .marquee-content:hover {
  23.   animation-play-state: paused;
  24. } 
  25. @keyframes scrolling {
  26.   0% { transform: translateX(0); }
  27.   100% { transform: translateX(calc(-1 * var(--marquee-element-width) * var(--marquee-elements))); }
  28. }
  29. .marquee-content li {
  30.   display: flex;
  31.   justify-content: center;
  32.   align-items: center;
  33.   flex-shrink: 0;
  34.   width: var(--marquee-element-width);
  35.   max-height: 100%;
  36.   white-space: nowrap;
  37. }
  38. .marquee-content li div {
  39.     display: block;
  40.     border-left: 1px solid transparent;
  41.     border-right: 1px solid #ccc;
  42.     padding: 0 20%;
  43.     width: 100%;
  44.     text-align: center;
  45. }
  46. @media (min-width: 576px) {
  47.   :root {
  48.     --marquee-elements-displayed: {{ displayed.sm }};
  49.   }
  50. }
  51. @media (min-width: 768px) {
  52.   :root {
  53.     --marquee-elements-displayed: {{ displayed.md }};
  54.   }
  55. }
  56. @media (min-width: 992px) {
  57.   :root {
  58.     --marquee-elements-displayed: {{ displayed.lg }};
  59.   }
  60. }
  61. @media (min-width: 1200px) {
  62.   :root {
  63.     --marquee-elements-displayed: {{ displayed.xl }};
  64.   }
  65. }
  66. @media (min-width: 1400px) {
  67.   :root {
  68.     --marquee-elements-displayed: {{ displayed.xxl }};
  69.   }
  70. }
  71. </style>
  72. <div class="marquee">
  73.   <ul class="marquee-content">
  74.       {% for url,image in partenaires %}
  75.           <li>
  76.             <div>
  77.             {% if url != '' %}
  78.               <a href="{{ url }}" target="_blank"><img class="img-fluid" src="{{ asset('assets/media/accueil/partenaires_2/' ~ image) }}" /></a>
  79.             {% else%}
  80.               <img class="img-fluid" src="{{ asset('assets/media/accueil/partenaires_2/' ~ image) }}" />
  81.             {% endif %}
  82.             </div>
  83.           </li>
  84.       {% endfor %}
  85.   </ul>
  86. </div>
  87. <script>
  88.   const root = document.documentElement;
  89.   const marqueeElementsDisplayed = getComputedStyle(root).getPropertyValue("--marquee-elements-displayed");
  90.   const marqueeContent = document.querySelector(".marquee-content");
  91.   root.style.setProperty("--marquee-elements", marqueeContent.children.length);
  92.   for(let i=0; i<marqueeElementsDisplayed; i++) {
  93.     marqueeContent.appendChild(marqueeContent.children[i].cloneNode(true));
  94.   }
  95. </script>