单项轮播
$('.single-item').slick();
多项轮播
$('.multiple-items').slick({
infinite: true,
slidesToShow: 3,
slidesToScroll: 3
});
响应式
$('.responsive').slick({
dots: true,
infinite: false,
speed: 300,
slidesToShow: 4,
slidesToScroll: 4,
responsive: [
{
breakpoint: 1024,
settings: {
slidesToShow: 3,
slidesToScroll: 3,
infinite: true,
dots: true
}
},
{
breakpoint: 600,
settings: {
slidesToShow: 2,
slidesToScroll: 2
}
},
{
breakpoint: 480,
settings: {
slidesToShow: 1,
slidesToScroll: 1
}
}
]
});
一次轮播一个
$('.one-time').slick({
dots: true,
infinite: false,
speed: 300,
slidesToShow: 5,
touchMove: false,
slidesToScroll: 1
});
不均匀集
$('.uneven').slick({
slidesToShow: 4,
slidesToScroll: 4
});
中心模式
$('.center').slick({
centerMode: true,
centerPadding: '60px',
slidesToShow: 3,
responsive: [
{
breakpoint: 768,
settings: {
arrows: false,
centerMode: true,
centerPadding: '40px',
slidesToShow: 3
}
},
{
breakpoint: 480,
settings: {
arrows: false,
centerMode: true,
centerPadding: '40px',
slidesToShow: 1
}
}
]
});
延迟加载
// To use lazy loading, set a data-lazy attribute
// on your img tags and leave off the src
<img data-lazy="img/lazyfonz1.png"/>
$('.lazy').slick({
lazyLoad: 'ondemand',
slidesToShow: 3,
slidesToScroll: 1
});
自动播放
$('.autoplay').slick({
slidesToShow: 3,
slidesToScroll: 1,
autoplay: true,
autoplaySpeed: 2000,
});
渐变效果
$('.fade').slick({
dots: true,
infinite: true,
speed: 500,
fade: true,
slide: '> div',
cssEase: 'linear'
});
添加和删除
$('.add-remove').slick({
slidesToShow: 3,
slidesToScroll: 3
});
var slideIndex = 1;
$('.js-add-slide').on('click', function(){
slideIndex++;
$('.add-remove').slickAdd('<div><h3>'+slideIndex+'</h3></div>');
});
$('.js-remove-slide').on('click', function(){
$('.add-remove').slickRemove(slideIndex - 1);
if (slideIndex !== 0) {
slideIndex--;
}
});
过滤效果
$('.filtering').slick({
slidesToShow: 4,
slidesToScroll: 4
});
var filtered = false;
$('.js-filter').on('click', function(){
if(filtered === false) {
$('.filtering').slickFilter(':even');
$(this).text('Unfilter Slides');
filtered = true;
} else {
$('.filtering').slickUnfilter();
$(this).text('Filter Slides');
filtered = false;
}
});
摧毁
If you really want to be that guy...
$('.your-slider').unslick();