码迷,mamicode.com
首页 > Web开发 > 详细

jquery幻灯片

时间:2016-12-02 01:12:11      阅读:179      评论:0      收藏:0      [点我收藏+]

标签:lis   jquery   var   remove   img   jquer   stop   pos   over   

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        *{
            margin: 0;
            padding: 0;
            list-style: none;
        }
        #wrap {
            width: 590px;
            height: 340px;
            position: relative;
            overflow: hidden;
            margin: 100px auto;
            border: #333 2px solid;
        }

        #wrap ol{
            position: absolute;
            left: 50%;
            bottom: 10px;
            margin-left: -70px;
        }
        #wrap ol li{
            width: 30px;
            height: 30px;
            background: #ccc;
            float: left;
            margin-right: 5px;
            border-radius: 50%;
        }
        #wrap ul {
            position: absolute;
            height: 340px;
        }
        #wrap ul li{
            width: 590px;
            height: 340px;
        }

        #wrap ol li.active{
            background: red;
        }
    </style>
    <script src="jquery.min.js"></script>
    <script>
        $(function(){
            var aBtn = $(‘#wrap ol li‘);
            var oUl = $(‘#wrap ul‘);

            aBtn.hover(function(){
                aBtn.removeClass(‘active‘);
                $(this).addClass(‘active‘);
                oUl.stop().animate({top:-340*$(this).index()});
            });
        });
    </script>
</head>
<body>
<div id="wrap">
    <ul>
        <li><img src="img/s1.jpg" /></li>
        <li><img src="img/s2.jpg" /></li>
        <li><img src="img/s3.jpg" /></li>
        <li><img src="img/s4.jpg" /></li>
    </ul>
    <ol>
        <li class="active"></li>
        <li></li>
        <li></li>
        <li></li>
    </ol>
</div>
</body>
</html>

jquery幻灯片

标签:lis   jquery   var   remove   img   jquer   stop   pos   over   

原文地址:http://www.cnblogs.com/guolimin/p/6123562.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!