unslider制作轮播图

    xiaoxiao2022-06-23  17

    unslider 使用演示

    本插件可配合jquery.event.swipe.js来实现触摸响应,具体请参见jquery.event.swipe.js的使用说明。

    1-首先我们定义一个固定的大小的DIV(id=”b04”),使用固定大小的图片(width=”640” height=”480”),并限制容器大小(#b04 { width: 640px;})


    2-添加左右箭头指示,单击时候不让他跳转(href=”javascript:void(0)),并设置一个类(class=”unslider-arrow04 next”)让他滑动到下一个图片。


    3-在整个文档加载完成时执行一个回调函数($(document).ready(function(){ }))在这个函数中使用unslider 插件即可。


    HTML

    <div class="banner" id="b04"> <ul> <li><img src="01.jpg" alt="" width="640" height="480" ></li> <li><img src="02.jpg" alt="" width="640" height="480" ></li> <li><img src="03.jpg" alt="" width="640" height="480" ></li> <li><img src="04.jpg" alt="" width="640" height="480" ></li> <li><img src="05.jpg" alt="" width="640" height="480" ></li> </ul> <a href="javascript:void(0);" class="unslider-arrow04 prev"><img class="arrow" id="al" src="arrowl.png" alt="prev" width="20" height="35"> </a> <a href="javascript:void(0);" class="unslider-arrow04 next"><img class="arrow" id="ar" src="arrowr.png" alt="next" width="20" height="37"> </a> </div>

    CSS

    #b04 { width: 640px;} #b04 .dots { position: absolute; left: 0; right: 0; bottom: 20px;} #b04 .dots li { display: inline-block; width: 10px; height: 10px; margin: 0 4px; text-indent: -999em; border: 2px solid #fff; border-radius: 6px; cursor: pointer; opacity: .4; -webkit-transition: background .5s, opacity .5s; -moz-transition: background .5s, opacity .5s; transition: background .5s, opacity .5s; } #b04 .dots li.active { background: #fff; opacity: 1; } #b04 .arrow { position: absolute; top: 200px;} #b04 #al { left: 15px;} #b04 #ar { right: 15px;}

    JS

    $(document).ready(function(e) { var unslider04 = $('#b04').unslider({ dots: true }), data04 = unslider04.data('unslider'); $('.unslider-arrow04').click(function() { var fn = this.className.split(' ')[1]; data04[fn](); }); });
    转载请注明原文地址: https://ju.6miu.com/read-1123195.html

    最新回复(0)