美文网首页
多图片轮播图

多图片轮播图

作者: Yoyo_UoU | 来源:发表于2017-03-30 23:48 被阅读0次

    HTML code

    <div class="box">
        <ul>
            <li>![](img/bg3.1.jpg)</li>
            <li>![](img/gf.jpg)</li>
            <li>![](img/myg.jpg)</li>
            <li>![](img/hhy.jpg)</li>
            <li>![](img/jsjx2.jpg)</li>
            <li>![](img/kbgs1.jpg)</li>
        </ul>
        <div class="prev"></div>
        <div class="next"></div>
    </div>
    

    CSS code

            body,
            div,
            ul,
            li,
            img {
                margin: 0;
                padding: 0;
            }
    
            body {
                background-color: #68B;
            }
    
            .box {
                width: 1180px;
                height: 236px;
                margin: 40px 0 0 50px;
                position: relative;
                z-index: 1;
            }
    
            ul {
                width: 1200px;
                height: 236px;
                position: relative;
                z-index: 1;
                display: block;
            }
    
            li {
                list-style: none;
                float: left;
                position: relative;
                margin-right: 20px;
            }
    
            img {
                width: 180px;
                height: 236px;
            }
             <!--精灵图的设置-->
            .prev, .next {
                width: 30px;
                height: 50px;
                background: url(左右轮播/images/icon.png) no-repeat;
                background: url(左右轮播/images/icon_ie6.png) no-repeat \9;
                opacity: .7;
                margin-top: -12%;
                position: absolute;
                z-index: 2;
            }
    
            .prev:hover, .next:hover {
                opacity: .9;
            }
    
            .prev {
                background-position: 0 -60px;
                left: 4px;
            }
    
            .next {
                background-position: 0 0;
                right: 4px;
            }
    ##    jQ code
    <script src="jquery-3.1.1.min.js"></script>
    <script>
        $(document).ready(function () {
            var ul = $("ul"),
                lis = $("li"),
                prev = $(".prev"),
                liF = lis.eq(0),
                liL = lis.eq(5),
                next = $(".next");
            prev.click(function () {
                if (liF) {
                    ul.append($('li:nth-of-type(1)'));
                }
            });
            next.click(function () {
                if (liL) {
                    ul.prepend($('li:nth-of-type(6)'));
                }
            })
        });
    </script>
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    相关文章

      网友评论

          本文标题:多图片轮播图

          本文链接:https://www.haomeiwen.com/subject/bxjkottx.html