Click here to Skip to main content
15,881,852 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I am making a slider for reviews for my squarespace website, and the code works in the editor, but when i preview the site it turn verticle rather than horozontal. the arrows that im am trying to use to control the slider also is not working. What have I done wrong?

What I have tried:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick.min.css"/>
  <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick-theme.min.css"/>
  <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Montserrat:wght@700&family=Montserrat:ital,wght@1,700&display=swap">
  <style>
    body {
      font-family: 'Montserrat', sans-serif;
      margin: 0;
    }

    .testimonial-carousel {
      width: 100%;
      overflow: true;
      position: relative;
    }

    .slick-list {
      display: flex;
      gap: 20px; /* Separate cards by 25px */
      padding: 20px;
      margin: 0px;
    }

    .testimonial-card {
      flex: 0 0 calc(30% - 20px); /* Adjust card width and gap */
      background-color: #ffffff; /* White background */
      padding: 20px;
      border-radius: 0px;
      box-shadow: 0 0px 10px rgba(0, 0, 0, 0.1);
      text-align: left; /* Align content to the left */
      position: relative;
    }

    .stars-image {
      width: 140px; /* Adjust size as needed */
      margin-bottom: 2px;
    }

    .full-name {
      color: #000000; /* Black color */
      font-weight: 700;
      font-style: italic;
      margin-bottom: 3px;
    }

    .review-text {
      color: #747474;
      font-style: italic;
    }

    /* Slick Carousel Arrows */
    .slick-prev, .slick-next {
      font-size: 20px;
      color: #000000; /* Black color */
      background: transparent;
      border: none;
      cursor: pointer;
      position: absolute;
      bottom: 50px;
    }

    .slick-prev {
      left: 1250px;
      top: 340px;
    }

    .slick-next {
      right: 90px;
      top: 340px;
    }

    .slick-prev::before, .slick-next::before {
      content: '';
      display: block;
      width: 45px;
      height: 45px;
      background-size: contain;
    }

    .slick-prev::before {
      background-image: url('https://assets-global.website-files.com/63f8515f47f20342243f082c/63f8515f47f20392563f08c2_slider-arrow-left-autocar-webflow-ecommerce-template.svg');
    }

    .slick-next::before {
      background-image: url('https://assets-global.website-files.com/63f8515f47f20342243f082c/63f8515f47f20378e23f08c1_slider-arrow-right-autocar-webflow-ecommerce-template.svg');
    }
  </style>
</head>
<body>

<div class="testimonial-carousel">
  <div class="slick-list">
    <!-- Testimonial Card 1 -->
    <div class="testimonial-card">
      <img class="stars-image" src="https://assets-global.website-files.com/63f8515f47f20342243f082c/63f8515f47f20331c43f08c0_5-stars-testimonial-autocar-webflow-ecommerce-template.svg" alt="5 Stars">
      <div class="full-name">John Johnson</div>
      <div class="review-text">If you are looking for an honest, reliable and trustworthy auto detailer, look no further than Bryce at PrestigedetailSD.
He pays attention to every detail of the exterior and interiors.
He is fairly new to North County and does not have many reviews yet.
He is also very reasonable based on your needs.
      </div>
    </div>

    <!-- Duplicate the Testimonial Card 7 more times -->
    <!-- Testimonial Card 2 -->
    <div class="testimonial-card">
      <img class="stars-image" src="https://assets-global.website-files.com/63f8515f47f20342243f082c/63f8515f47f20331c43f08c0_5-stars-testimonial-autocar-webflow-ecommerce-template.svg" alt="5 Stars">
      <div class="full-name">Kurt Kellenberger</div>
      <div class="review-text">Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
    </div>

    <!-- Testimonial Card 3 -->
    <div class="testimonial-card">
      <img class="stars-image" src="https://assets-global.website-files.com/63f8515f47f20342243f082c/63f8515f47f20331c43f08c0_5-stars-testimonial-autocar-webflow-ecommerce-template.svg" alt="5 Stars">
      <div class="full-name">Alice Smith</div>
      <div class="review-text">Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</div>
    </div>

    <!-- Testimonial Card 4 -->
    <div class="testimonial-card">
      <img class="stars-image" src="https://assets-global.website-files.com/63f8515f47f20342243f082c/63f8515f47f20331c43f08c0_5-stars-testimonial-autocar-webflow-ecommerce-template.svg" alt="5 Stars">
      <div class="full-name">Bob Johnson</div>
      <div class="review-text">Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>
    </div>

    <!-- Testimonial Card 5 -->
    <div class="testimonial-card">
      <img class="stars-image" src="https://assets-global.website-files.com/63f8515f47f20342243f082c/63f8515f47f20331c43f08c0_5-stars-testimonial-autocar-webflow-ecommerce-template.svg" alt="5 Stars">
      <div class="full-name">Mary Johnson</div>
      <div class="review-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</div>
    </div>

    <!-- Testimonial Card 6 -->
    <div class="testimonial-card">
      <img class="stars-image" src="https://assets-global.website-files.com/63f8515f47f20342243f082c/63f8515f47f20331c43f08c0_5-stars-testimonial-autocar-webflow-ecommerce-template.svg" alt="5 Stars">
      <div class="full-name">Emily Johnson</div>
      <div class="review-text">Quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
    </div>

    <!-- Testimonial Card 7 -->
    <div class="testimonial-card">
      <img class="stars-image" src="https://assets-global.website-files.com/63f8515f47f20342243f082c/63f8515f47f20331c43f08c0_5-stars-testimonial-autocar-webflow-ecommerce-template.svg" alt="5 Stars">
      <div class="full-name">Michael Johnson</div>
      <div class="review-text">Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam.</div>
    </div>

    <!-- Testimonial Card 8 -->
    <div class="testimonial-card">
      <img class="stars-image" src="https://assets-global.website-files.com/63f8515f47f20342243f082c/63f8515f47f20331c43f08c0_5-stars-testimonial-autocar-webflow-ecommerce-template.svg" alt="5 Stars">
      <div class="full-name">Laura Johnson</div>
      <div class="review-text">Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</div>
    </div>
  </div>

  <!-- Slick Carousel Arrows -->
  <button type="button" class="slick-prev"></button>
  <button type="button" class="slick-next"></button>
</div>

<!-- Include jQuery and Slick Carousel JS -->
<script type="text/javascript" src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick.min.js"></script>

<script>
  $(document).ready(function(){
    $('.testimonial-carousel').slick({
      slidesToShow: 4, // Set the number of cards to show horizontally
      slidesToScroll: 4,
      autoplay: true,
      autoplaySpeed: 5000,
      dots: false,
      arrows: true,
      prevArrow: '<button type="button" class="slick-prev"></button>',
      nextArrow: '<button type="button" class="slick-next"></button>'
    });
  });
</script>

</body>
</html>
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900