jquery - 如何在 Owl carousel 中显示多个项目?
问题描述
我在我的页面上使用 Owl 轮播。我需要在多个部分中使用它,但每个部分都有不同的轮播设计。
在我的第一个轮播部分,我需要一次显示两个项目,但在另一个部分,我需要一次显示 4 个项目。
在我的 js 文件中,我像这样初始化轮播:
$(document).ready(function(){
$(".owl-carousel").owlCarousel(
{
items: 2,
slideBy: 2
}
);
});
但是如果我这样做,那么我只能在每个部分中显示 2 个项目。有没有办法以某种方式改变items
,取决于部分?
谢谢
解决方案
owl-carousel
和owl-theme
默认样式。你可以像这样为每个轮播写不同的类
<div class="owl-carousel owl-theme first-slider"></div>
<div class="owl-carousel owl-theme second-slider"></div>
<div class="owl-carousel owl-theme third-slider"></div>
$(".first-slider").owlCarousel(
//owl setting
);
$(".second-slider").owlCarousel(
//owl setting
);
$(".third-slider").owlCarousel(
//owl setting
);
推荐阅读
- angular - Angular 6 递归路由定义
- php - PHP使用单值查询
- php - Web 服务器迁移后 LDAP 身份验证不起作用
- javascript - 意外的行为jquery
- javascript - 如何在列表视图 Visual Studio LightSwitch 顶部添加多选复选框
- google-api - 通过日历 api 在特定时间安排谷歌日历邀请
- html - 保存和加载动态创建的可拖动元素的位置(jQuery-UI)
- amazon-web-services - EMR 命令运行程序如何提交作业
- sql - Google Data Studio (BigQuery) - 创建过滤器以按最新时间选择
- itext - ITextSharp v5.5.13.0 XMLWorker 土耳其语字符问题