最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to add your customise arrows in slick slider JS using CSS - Stack Overflow

programmeradmin4浏览0评论

How do I add my very own customise arrows to slick slider. I have manage to override the default buttons of slick slider. But my very own customise arrows do not seem to show. What can I do to resolve this issue?

 

$(document).ready(function(){
      $('.slider').slick({
        slidesToShow: 1, 
        slidesToScroll: 1, 
        autoplay: true, 
        autoplaySpeed: 2000,
		arrows: true,
       prevArrow: '<div class="slick-prev"></div>',
       nextArrow: '<div class="slick-next"></div>'
      });
});
.slick-next {
 background: url('../img/right-arrow.png') no-repeat;
}
.slick-prev {
 background: url('../img/left-arrow.png') no-repeat;
}
<section id="testimonial"> <!-- Testimonial section -->
    <div class="slider"> 
      <div><img src="img/testimonial-1.png" alt="Testimonial from Bartholomew Watson of Abicord Consulting"></div>  
      <div><img src="img/testimonial-2.png" alt="Testimonial from Dwayne Ferguson of CC Collect"></div>
      <div><img src="img/testimonial-3.png" alt="Testimonial from David Jamilly of Kindness UK"></div>
      <div><img src="img/testimonial-4.png" alt="Testimonial from Sergey Slepov of Credit Suisse"></div>
    </div>
   </section>

How do I add my very own customise arrows to slick slider. I have manage to override the default buttons of slick slider. But my very own customise arrows do not seem to show. What can I do to resolve this issue?

 

$(document).ready(function(){
      $('.slider').slick({
        slidesToShow: 1, 
        slidesToScroll: 1, 
        autoplay: true, 
        autoplaySpeed: 2000,
		arrows: true,
       prevArrow: '<div class="slick-prev"></div>',
       nextArrow: '<div class="slick-next"></div>'
      });
});
.slick-next {
 background: url('../img/right-arrow.png') no-repeat;
}
.slick-prev {
 background: url('../img/left-arrow.png') no-repeat;
}
<section id="testimonial"> <!-- Testimonial section -->
    <div class="slider"> 
      <div><img src="img/testimonial-1.png" alt="Testimonial from Bartholomew Watson of Abicord Consulting"></div>  
      <div><img src="img/testimonial-2.png" alt="Testimonial from Dwayne Ferguson of CC Collect"></div>
      <div><img src="img/testimonial-3.png" alt="Testimonial from David Jamilly of Kindness UK"></div>
      <div><img src="img/testimonial-4.png" alt="Testimonial from Sergey Slepov of Credit Suisse"></div>
    </div>
   </section>

Share Improve this question edited Jan 20, 2016 at 7:39 Aki 2,9381 gold badge17 silver badges23 bronze badges asked Jan 20, 2016 at 6:32 Umair YaquoobUmair Yaquoob 591 gold badge2 silver badges8 bronze badges 2
  • 1 add your code jsfiddle – Lalji Tadhani Commented Jan 20, 2016 at 6:34
  • Your js isn't adding the <div class="slick-prev"></div> or <div class="slick-next"></div> to the html, and I know nothing about js – Carol McKay Commented Jan 20, 2016 at 7:01
Add a ment  | 

2 Answers 2

Reset to default 2

This worked for me:

.slick-prev:before {
  content: url('your-left-arrow.png');
}
.slick-next:before {
  content: url('your-right-arrow.png');
}
Use CSS like below,you can change the dimension of images as per your custom   arrow images.

<pre>

.slick-next::before {
        background: url('../img/right-arrow.png') no-repeat;
        content: "";
        display: block;
        height: 15px;
        width: 15px;
}
.slick-prev {
        background: url('../img/left-arrow.png') no-repeat;
        content: "";
        display: block;
        height: 15px;
        width: 15px;
}
</pre>
发布评论

评论列表(0)

  1. 暂无评论