zoukankan      html  css  js  c++  java
  • 淡入淡出轮播图

    <!DOCTYPE html>
    <html>
    <head>
    <style type="text/css">

    body{background:#57beb9;}
    /* main */
    #main{920px;height:430px;overflow:hidden;position:relative;margin:30px auto;}
    #main .box{820px;height:430px;box-shadow:0px 0px 5px #ddd;margin:0px auto;overflow:hidden;position:relative;}
    #main .box img{820px;height:430px;position:absolute;left:0px;top:0px;opacity:0;filter:alpha(opacity=0);}
    #main .btnLeft{35px;height:57px;position:absolute;left:0px;top:185px;background:url(images/left_ar.png) no-repeat 0px 0px;}
    #main .btnRight{35px;height:57px;position:absolute;right:0px;top:185px;background:url(images/right_ar.png) no-repeat 0px 0px;}
    #main .page{132px;height:22px;position:absolute;bottom:15px;right:50px;}
    #main .page a{display:inline-block;22px;height:22px;background:url(images/num_grey.png) no-repeat 0px 0px;margin:0px 11px;float:left;color:#FFF;text-decoration:none;text-align:center;}
    #main .page a.active{background:url(images/num_red.png) no-repeat 0px 0px;}

    </style>
    </head>
    <body>
    <div id="main">
    <a class="btnLeft" id="btnLeft" href="javascript:void(0);"></a>
    <a class="btnRight" id="btnRight" href="javascript:void(0);"></a>
    <div class="box">
    <img style="opacity: 1;" src="images/intro1.jpg">
    <img src="images/intro2.jpg" style="opacity: 0;">
    <img src="images/intro3.jpg" style="opacity: 0;">
    </div>
    <div class="page">
    <a class="active" href="javascript:void(0);">1</a>
    <a href="javascript:void(0);" class="">2</a> <a href="javascript:void(0);" class="">3</a>
    </div>
    </div>
    <script type="text/javascript" src="jquery-1.11.0.min.js"></script>
    <script type="text/javascript">

    $(function(){

    var aPage = $('#main .page a');
    var aImg = $('#main .box img');
    var iSize = aImg.size();
    var index = 0;
    var t;
    $('#btnLeft').click(function(){
    index--;
    if(index<0){
    index=iSize-1
    }
    change(index)
    })
    $('#btnRight').click(function(){
    index++;
    if(index>iSize-1){
    index=0
    }
    change(index)
    })

    aPage.click(function(){
    index = $(this).index();
    change(index)
    });

    function change(index){
    aPage.removeClass('active');
    aPage.eq(index).addClass('active');
    aImg.stop();

    aImg.eq(index).siblings().animate({
    opacity:0
    },1000)

    aImg.eq(index).animate({
    opacity:1
    },1000)
    }


    function autoshow() {
    index=index+1;
    if(index<=iSize-1){
    change(index);
    }else{
    index=0;
    change(index);
    }

    }
    int=setInterval(autoshow,3000);
    function clearInt() {
    $('#btnLeft,#btnRight,.page a').mouseover(function() {
    clearInterval(int);
    })

    }
    function setInt() {
    $('#btnLeft,#btnRight,.page a').mouseout(function() {
    int=setInterval(autoshow,3000);
    })
    }
    clearInt();
    setInt();
    })

    </script>
    </body>
    </html>

  • 相关阅读:
    redis 持久化RDB、AOF
    进程、线程、协程
    nginx 常用配置
    Redis详解(一)
    Nginx(一)
    docker compose
    练习1——排序
    8万行的insert数据,Ctrl+c、Ctrl+v后心态崩了(如何在Linux下对MySQL数据库执行sql文件)
    Ubuntu使用+Thinkphp5学习——20(html文件中代码注释掉,但是runtime/temp中的php文件仍然存在)
    Ubuntu使用+Thinkphp5学习——19(新增用户报错strip_tags() expects parameter 1 to be string, array given)
  • 原文地址:https://www.cnblogs.com/xiaotaiyang/p/5512819.html
Copyright © 2011-2022 走看看