• jquery图片无缝滚动代码左右 上下无缝滚动图片


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>jquery图片无缝滚动代码左右上下无缝滚动图片</title>
    <meta name="description" content="jquery图片无缝滚动插件制作左右无缝滚动图片和上下无缝滚动图片,一款简单的jQuery无缝滚动代码。" />
    </head>
    
    <body>
    <script src="js/jquery-1.4.2.min.js" type="text/javascript"></script>
    <script type="text/javascript">
    //图片滚动 调用方法 imgscroll({speed: 30,amount: 1,dir: "up"});
    $.fn.imgscroll = function(o){
        var defaults = {
            speed: 40,
            amount: 0,
             1,
            dir: "left"
        };
        o = $.extend(defaults, o);
        
        return this.each(function(){
            var _li = $("li", this);
            _li.parent().parent().css({overflow: "hidden", position: "relative"}); //div
            _li.parent().css({margin: "0", padding: "0", overflow: "hidden", position: "relative", "list-style": "none"}); //ul
            _li.css({position: "relative", overflow: "hidden"}); //li
            if(o.dir == "left") _li.css({float: "left"});
            
            //初始大小
            var _li_size = 0;
            for(var i=0; i<_li.size(); i++)
                _li_size += o.dir == "left" ? _li.eq(i).outerWidth(true) : _li.eq(i).outerHeight(true);
            
            //循环所需要的元素
            if(o.dir == "left") _li.parent().css({ (_li_size*3)+"px"});
            _li.parent().empty().append(_li.clone()).append(_li.clone()).append(_li.clone());
            _li = $("li", this);
    
            //滚动
            var _li_scroll = 0;
            function goto(){
                _li_scroll += o.width;
                if(_li_scroll > _li_size)
                {
                    _li_scroll = 0;
                    _li.parent().css(o.dir == "left" ? { left : -_li_scroll } : { top : -_li_scroll });
                    _li_scroll += o.width;
                }
                    _li.parent().animate(o.dir == "left" ? { left : -_li_scroll } : { top : -_li_scroll }, o.amount);
            }
            
            //开始
            var move = setInterval(function(){ goto(); }, o.speed);
            _li.parent().hover(function(){
                clearInterval(move);
            },function(){
                clearInterval(move);
                move = setInterval(function(){ goto(); }, o.speed);
            });
        });
    };
    </script>
    
    <style type="text/css">
    *{margin:0;padding:0;list-style-type:none;}
    a,img{border:0;}
    body{font:12px/180% Arial, Helvetica, sans-serif, "新宋体";}
    /* scrollleft */
    .scrollleft{width:680px;padding:5px 20px 0px 20px;margin:20px auto;}
    .scrollleft li{float:left;margin-right:7px;display:inline;width:158px;text-align:center;line-height:19px}
    .scrollleft img{width:136px;height:100px;padding:10px;border:solid 1px #ddd;}
    /* scrolltop */
    .scrolltop{width:158px;height:438px;overflow:hidden;margin:20px auto;}
    .scrolltop li{height:156px;overflow:hidden;text-align:center;line-height:19px}
    .scrolltop img{width:136px;height:100px;padding:10px;border:solid 1px #ddd;}
    </style>
    
    <div class="scrollleft">
        <ul>
            <li>
                <a href="http://www.17sucai.com"><img width="136" height="100" alt="卷板" src="images/123a.jpg"/></a>
                <span>卷板</span>
            </li>
            <li>
                <a href="http://www.17sucai.com"><img width="136" height="100" alt="钢板" src="images/2146.jpg"/></a>
                <span>钢板</span>
            </li>
            <li>
                <a href="http://www.17sucai.com"><img width="136" height="100" alt="卷板" src="images/as12.jpg"/></a>
                <span>卷板</span>
            </li>
        </ul>
    </div>
    
    <div class="scrolltop">
        <ul>
            <li>
                <a href="http://www.17sucai.com"><img width="136" height="100" alt="卷板" src="images/123a.jpg"/></a>
                <span>卷板</span>
            </li>
            <li>
                <a href="http://www.17sucai.com"><img width="136" height="100" alt="钢板" src="images/2146.jpg"/></a>
                <span>钢板</span>
            </li>
            <li>
                <a href="http://www.17sucai.com"><img width="136" height="100" alt="卷板" src="images/as12.jpg"/></a>
                <span>卷板</span>
            </li>
        </ul>
    </div>
    
    
    <script type="text/javascript">
    $(document).ready(function(){
    
        $(".scrollleft").imgscroll({
            speed: 40,    //图片滚动速度
            amount: 0,    //图片滚动过渡时间
             1,     //图片滚动步数
            dir: "left"   // "left" 或 "up" 向左或向上滚动
        });
        
        $(".scrolltop").imgscroll({
            speed: 40,    //图片滚动速度
            amount: 0,    //图片滚动过渡时间
             1,     //图片滚动步数
            dir: "up"   // "left" 或 "up" 向左或向上滚动
        });
        
    });
    </script> 
    
    </body>
    </html>
  • 相关阅读:
    操作系统进程通信
    操作系统进程调度
    java中的变量
    java移位运算符
    String, StringBuffer, StringBuilder 的区别
    多线程相关问题汇总
    java内存管理与GC机制(二)
    java内存管理与GC机制(一)
    进程与线程的理解
    Liferay7使用maven引入第三方jar包
  • 原文地址:https://www.cnblogs.com/qigege/p/4762110.html
Copyright © 2020-2023  润新知