如何使用CSS

时间:2016-01-20 06:32:31

标签: javascript jquery html css

如何将自己的自定义箭头添加到光滑滑块。我已设法覆盖光滑滑块的默认按钮。但我自己的自定义箭头似乎没有显示。我该怎么做才能解决这个问题?

 

$(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>

2 个答案:

答案 0 :(得分:2)

这对我有用:

.slick-prev:before {
  content: url('your-left-arrow.png');
}
.slick-next:before {
  content: url('your-right-arrow.png');
}

答案 1 :(得分:0)

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>