Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Append slick arrows inside the slide content

I am using Slick for a slideshow, where I need the arrows to be inside the slide content, so I can position them relative to the slide content instead of the outer container. I use the appendArrows option for this, but then the arrows get appended multiple times and the navigation does not work anymore (also mentioned in this question). I need the arrows to appear left and right of the link (the headlines and link texts can have arbitrary length of course). Is there a way to achieve this?

JS:

$('.product-slideshow').slick({
  appendArrows: '.slider-nav'
});

HTML:

<div class="product-slideshow">
  <div class="slide">
    <div class="content-wrapper">
      <h2 class="text-xxl text-centered">Produkt 1</h2>
      <div class="slider-nav text-centered">
        <a href="#product-1">zum Produkt</a>
      </div>
      <img src="/inc/images/product-1.jpg" alt="Beschreibung Produkt 1" />
    </div>
  </div>
  <div class="slide">
    <div class="content-wrapper">
      <h2 class="text-xxl text-centered">Produkt 2</h2>
      <div class="slider-nav text-centered">
        <a href="#product-2">zum Produkt</a>
      </div>
      <img src="/inc/images/product-2.jpg" alt="Beschreibung Produkt 2" />
    </div>
  </div>
</div>
like image 744
josi Avatar asked May 09 '17 15:05

josi


2 Answers

Yes, you can simply add in the html elements you wish to use as arrows and then select them to be used as the previous or next arrow.

$('.product-slideshow').slick({
    prevArrow: $('.prev-slide'),
    nextArrow: $('.next-slide'),
});

In this example you could have an html element with the class of .prev-slide used for the back arrow and an element with the class of .next-slide for the forward arrow.

like image 167
Neil K Avatar answered Oct 24 '22 11:10

Neil K


As for your personal project, you can accomplish this very easy using the appendArrows option:

$(".slider").slick({  
    appendArrows: ".container"
});
like image 31
Roman Balyk Avatar answered Oct 24 '22 10:10

Roman Balyk