zoukankan      html  css  js  c++  java
  • 简单的Jquery轮播

    <html>
        <head>
            <title>轮播</title>
            <style>
            *{
            margin:0;
            padding:0;
            list-style:none;
            }
                #dingwei{
                    position:absolute;
                    width:300px;
                    height:300px;
                    left:300px;
                    top:100px;
                    overflow: hidden;
                }
                #dingwei ul{
                    width: 300px; 
                    height:300px;
                }
                #dingwei ul li{
                display:inline;
                float:left;
                position:absolute;
                }
            #dingwei ul img{
                width:300px;
                height:300px;
            }
            #dingwei>span{
                position:absolute;
                z-index:99;
                width:10%;
                height:40px;
                font-size:50px;
                top:40%;
                line-height:100%;
                text-align:center;
                cursor:pointer;
                display:none;
            }
            #right{
                left:90%;
            }
            </style>
            <script src="jquery-3.1.1.min.js">
            
            </script>
        </head>
        <body>
            <div id="dingwei">
                <span id="left">&lt;</span>
                <span id="right">&gt;</span>
                <ul id="pics">
                    <li style="z-index:4"><a><img src="1.jpg"/></a></li>
                    <li style="z-index:3"><a><img src="2.jpg"/></a></li>
                    <li style="z-index:2"><a><img src="3.jpg"/></a></li>
                    <li style="z-index:1"><a><img src="4.jpg"/></a></li>
                </ul>
                
            </div>
    
            <script>
                $(document).ready(function(){
                    $("#dingwei").mouseover(function(){
                        $("#dingwei span").css("display","block");
                    });
                    $("#dingwei").mouseout(function(){
                        $("#dingwei span").css("display","none");
                    });
                    $("#right").click(function(){
                        var last=$("#pics li").last();
                        $(last).css({"left":-($("#pics img").width()),"z-index":"5"});
                        $(last).animate({left:0},function(){    
                            $("#pics li").each(function(){                
                                $(this).css("z-index",parseInt($(this).css("z-index"))-1);
                            });
                            $("#pics li").first().before($(last));
                        });
                    });
                    $("#left").click(function(){
                        var first=$("#pics li").first();
                            $(first).animate({left:-$(first).find("img").width()},function(){
                                    var d="#pics li:not(:eq("+$("#pics li").index($(first))+"))";
                                        $(d).each(function(){
                                            var zindex=parseInt($(this).css("z-index"));
                                            $(this).css("z-index",zindex+1);
                                        });
                                    
                                    $("#pics").append($(first).detach().css({"z-index":"1","left":"0"}));
                                
                            });
                    });
                });
            </script>
        </body>
    </html>
    Hold on, everything is possible.
  • 相关阅读:
    OpenCV4Android——No implementation found for native Lorg/opencv/core/Mat;.n_Mat ()J
    The method onClick(View) of type new View.OnClickListener(){} must override a superclass
    Android与OpenCV——重新下载安装和OpenCV匹配的Android开发环境
    45_拍照
    32_文件断点上传器
    31_多线程断点下载器
    Eclipse的Servers视图中无法添加Tomcat
    23_网络通信之网络图片查看器
    C语言 · 时间转换
    C语言 · 4_2找公倍数
  • 原文地址:https://www.cnblogs.com/student-note/p/6501463.html
Copyright © 2011-2022 走看看