首页 > Web开发 > 详细

jQuery无缝滚动向上

时间:2015-10-31 01:35:45      阅读:346      评论:0      收藏:0      [点我收藏+]
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>绑定事件</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .div{
            width: 200px;
            height: 240px;
            overflow: hidden;
            position: relative;
            border: 1px solid #d74147;
        }
        .div ul{
            width: 200px;
            height: 240px;
            position: absolute;
            margin: 0;
            padding: 0;
            
        }
        .div ul li{
            width: 200px;
            height: 60px;
            list-style-type: none;
        }
    </style>
    <script src="js/jquery-1.7.1.js"></script>
    <script>
        $(function(){

            //复制与现有的Li一样多个
            $(‘ul‘).find(‘li‘).clone().appendTo($(‘ul‘));
            $(‘ul‘).height($(‘ul‘).find(‘li‘).length * $(‘ul‘).find(‘li‘).height());
            setInterval(function() {
                if($(‘ul‘).position().top < -$(‘ul‘).height()/2){
                    $(‘ul‘).css(‘top‘,‘0‘);
                }
                else{
                    $(‘ul‘).css(‘top‘,$(‘ul‘).position().top - 2 + ‘px‘);
                }

            },30);
        });

    </script>
</head>
<body>
<div class="div" id="div1">
    <ul>
        <li><img src="img/1.jpg" /></li>
        <li><img src="img/1.jpg" /></li>
        <li><img src="img/1.jpg" /></li>
        <li><img src="img/1.jpg" /></li>

    </ul>
</div>
</body>
</html>

  

jQuery无缝滚动向上

原文:http://www.cnblogs.com/shenq/p/4924727.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!