jQuery旋转木马插件(Owl Carousel 2)

下载地址:https://owlcarousel2.github.io/OwlCarousel2/

参考文档:http://www.htmleaf.com/jQuery/Slideshow-Scroller/201502161387.html

 

css引入:

<link rel="stylesheet" href="owlcarousel/owl.theme.default.min.css">   

 

js尾部添加 jquery.js 和 owl.carousel.min.js 文件 :

<script src="owlcarousel/owl.carousel.min.js"></script> 

 

 

HTML示例:

<div class="owl-carousel owl-theme">
    <div class="item"><h4>1</h4></div>
    <div class="item"><h4>2</h4></div>
    <div class="item"><h4>3</h4></div>
    <div class="item"><h4>4</h4></div>
    <div class="item"><h4>5</h4></div>
    <div class="item"><h4>6</h4></div>
    <div class="item"><h4>7</h4></div>
    <div class="item"><h4>8</h4></div>
    <div class="item"><h4>9</h4></div>
    <div class="item"><h4>10</h4></div>
    <div class="item"><h4>11</h4></div>
    <div class="item"><h4>12</h4></div>
</div>

 

js 示例:

$(document).ready(function(){
    /**
     * owl-carousel
     */
    var owl = $('.owl-carousel');
    owl.owlCarousel({
        items:4,  //在屏幕中可见的旋转木马项
        loop:true,  //是否无限循环,会复制第一项和最后一项来制作无限循环的错觉
        margin:10,  //图片间距10px
        autoplay:true,  //旋转木马是否自动播放
        autoplayTimeout:3000,  //旋转木马自动播放的时间间隔
        autoplayHoverPause:true,  //是否在鼠标滑过时停止自动播放
        dots:false  //显示圆点导航按钮
    });
});

 

效果参考(来自官网,按照我的js配置,圆点和导航箭头去掉了):

 

 

 

                    下表中是所有内置的Owl Carousel参数选项:

 

 

参数名称参数类型默认值描述
itemsType: NumberDefault: 3在屏幕中可见的旋转木马项
marginType: NumberDefault: 0旋转木马项的margin-right值,单位像素
loopType: BooleanDefault: false是否无限循环,会复制第一项和最后一项来制作无限循环的错觉
centerType: BooleanDefault: false旋转木马项居中。在奇数和偶数项中都可以很好的工作
mouseDragType: BooleanDefault: true是否可以使用鼠标拖拽
touchDragType: BooleanDefault: true是否可以触摸拖拽
pullDragType: BooleanDefault: trueStage pull to edge.
freeDragType: BooleanDefault: falseItem pull to edge
stagePaddingType: NumberDefault: 0Stage上的Padding left和Padding right(可以看到相邻的项)
mergeType: BooleanDefault: false合并旋转木马项。Looking for data-merge='{number}' inside item..
mergeFitType: BooleanDefault: true如果屏幕比旋转木马项小,使旋转木马项适合屏幕大小
autoWidthType: BooleanDefault: false设置非网格内容。尝试在div上使用width样式
startPositionType: Number/StringDefault: 0开始点或URL Hash字符串,如:'#id'
URLhashListenerType: BooleanDefault: false监听url hash 的变化。必须在旋转木马项上设置data-hash属性
navType: BooleanDefault: false显示ext/prev按钮
navRewindType: BooleanDefault: true跳转到前一项或后一项
navTextType: ArrayDefault: ['next','prev']HTML箭头导航
slideByType: Number/StringDefault: 1Navigation slide by x. 'page' string can be set to slide by page.
dotsType: BooleanDefault: true显示圆点导航按钮
dotsEachType: Number/BooleanDefault: false每多少个项显示一个圆点导航按钮
dotDataType: BooleanDefault: false使用data-dot的内容
lazyLoadType: BooleanDefault: false是否懒加载图片。data-srcdata-src-retina为高分辨率。如果元素不是<img>会设置为元素的内联背景图像。
lazyContentType: BooleanDefault: falselazyContent选项只在测试版中有,发行版中已经被删除。
autoplayType: BooleanDefault: false旋转木马是否自动播放
autoplayTimeoutType: NumberDefault: 5000旋转木马自动播放的时间间隔
autoplayHoverPauseType: BooleanDefault: false是否在鼠标滑过时停止自动播放
smartSpeedType: NumberDefault: 250速度计算
fluidSpeedType: BooleanDefault: Number速度计算
autoplaySpeedType: Number/BooleanDefault: false旋转木马自动播放的速度
navSpeedType: Number/BooleanDefault: false旋转木马导航的速度
dotsSpeedType: BooleanDefault: Number/Boolean分页的速度
dragEndSpeedType: Number/BooleanDefault: falseDrag end speed
callbacksType: BooleanDefault: true是否允许回调函数
responsiveType: ObjectDefault: empty object包含responsive选项的对象。设置为flase取消responsive能力。
responsiveRefreshRateType: NumberDefault: 200Responsive的刷新频率
responsiveBaseElementType: DOM elementDefault: window可以设置在任何DOM元素上。如果你关心不支持响应式的浏览器(如IE8),可以在包裹容器中使用该属性。
responsiveClassType: BooleanDefault: false可选的辅助class。添加owl-reponsive-breakpoint class到主元素上。可以在给定breakpoint的元素上设置内容样式。
videoType: BooleanDefault: false是否允许添加YouTube/Vimeo视频。
videoHeightType: Number/BooleanDefault: false设置视频的高度。
videoWidthType: Number/BooleanDefault: false设置视频的宽度。
animateOutType: String/BoleanDefault: falseCSS3 animation out.
animateInType: String/BoleanDefault: falseCSS3 animation in.
fallbackEasingType: StringDefault: swingEasing for CSS2 $.animate.
infoType: FunctionDefault: false获取基本信息的回调函数(当前的 item/pages/widths) 。Info函数的第二个参数是Owl DOM元素的对象引用。
nestedItemSelectorType: String/ClassDefault: false当owl元素嵌套在某些很深的DOM结构中时使用该参数。在class名字前面不要使用.号。
itemElementType: StringDefault: divowl-item的DOM元素类型。
stageElementType: StringDefault: divowl-stage.的DOM元素类型。
navContainerType: String/Class/ID/BoleanDefault: false设置自定义的导航容器class
dotsContainerType: String/Class/ID/BoleanDefault: false设置自定义的导航容器class

  

 

转载于:https://www.cnblogs.com/layla/p/11041563.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值