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.
  • 相关阅读:
    【数学】三分法
    【数学】【背包】【NOIP2018】P5020 货币系统
    【数学】【CF27E】 Number With The Given Amount Of Divisors
    【单调队列】【P3957】 跳房子
    【极值问题】【CF33C】 Wonderful Randomized Sum
    【DP】【CF31E】 TV Game
    【神仙题】【CF28D】 Don't fear, DravDe is kind
    【线段树】【CF19D】 Points
    【字符串】KMP字符串匹配
    【二维树状数组】【CF10D】 LCIS
  • 原文地址:https://www.cnblogs.com/student-note/p/6501463.html
Copyright © 2011-2022 走看看