0
我正在嘗試創建一個旋轉木馬,在桌面上有4x1佈局,在移動設備上有2x2佈局。Swiper Carousel:如何爲不同的屏幕尺寸給同一個旋轉木馬不同的屬性
這是代碼,但它只是打破了我的旋轉木馬。
var swiper1;
$(window).resize(function() {
var ww = $(window).width();
if (ww <= 767) {
swiper1 = new Swiper('#swiper2', {
slidesPerView: 2,
slidesPerColumn: 2,
spaceBetween: 10
}
);
}
else {
swiper1 = new Swiper('#swiper2', {
slidesPerView: 4,
slidesPerColumn: 1,
spaceBetween: 30
}
);
}
});
最初的代碼本來只是簡單:
var swiper1 = new Swiper('#swiper2', {
slidesPerView: 4,
slidesPerColumn: 1,
spaceBetween: 30
});
這是什麼爲我工作,但我想它更改爲2×2時分辨率爲< = 767
謝謝,這正是我需要的! – ksalah