我想创建一个网页,在手机屏幕上显示一张图片,但我可以滑动到下一张和上一张图片。然后在平板电脑屏幕上有2张图片,可以滑动到下一张和上一张,在媒体查询中调用这些图片,每张图片都能正常工作,但我想把它们都放在不同的屏幕尺寸上。
// showing single item
$('.your-class').slick();
// showing tablet
$('.multiple-items').slick({
infinite: true,
slidesToShow: 2,
slidesToScroll: 2
});
// SHOWING 4 COLUMN desktop
$('.multiple-items4').slick({
infinite: true,
slidesToShow: 4,
slidesToScroll: 4
});
你需要给 断点 为响应速度。
$('.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
}
}
// You can unslick at a given breakpoint now by adding:
// settings: "unslick"
// instead of a settings object
]
});
是的,知道了,非常感谢,这个代码现在可以用了。
$('.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
}
}
// You can unslick at a given breakpoint now by adding:
// settings: "unslick"
// instead of a settings object
]
});