jq-시차 회전식 윤방 기반

3801 단어
  • ![](img/slidepic1.jpg)
  • ![](img/slidepic2.jpg)
  • ![](img/slidepic3.jpg)
  • ![](img/slidepic4.jpg)
  • ![](img/slidepic5.jpg)
$(function(){
    var $slidepic = $('#slidepic');
    var aLi = $slidepic.find('li');
    var timer = null;
    var off = true;
    // li 
    var pos = [
        {
            width:564,
            height:330,
            left:34,
            top:0,
            opacity:0,
            z:2
        },
        {
            width:564,
            height:330,
            left:34,
            top:79,
            opacity:0.8,
            z:3
        },
        {
            width:800,
            height:500,
            left:200,
            top:0,
            opacity:1,
            z:4
        },
        {
            width:564,
            height:330,
            left:605,
            top:79,
            opacity:0.8,
            z:3
        },
        {
            width:564,
            height:330,
            left:605,
            top:0,
            opacity:0,
            z:2
        }
    ]
    // li 
    fnMove()
    // 
    $slidepic.find('.prev').on('click',function(){
        if(off){
            off = false;
            fnMove(true)    
        }
    })
    // 
    $slidepic.find('.next').on('click',function(){
        if(off){
            off = false;
            fnMove(false)   
        }
    })
    //li 
    function fnMove(b){
        if(typeof(b) != 'undefined'){// , li , 
            if(b){
                pos.push(pos.shift())
            }else{
                pos.unshift(pos.pop())
            }
        }
        $.each(pos, function(i, val) {
            aLi.eq(i).css('z-index',pos[i].z).stop().animate(pos[i],500,function(){
                off = true;
            });
        });
    }
    // 
    timer = setInterval(function(){
        fnMove(true)
    },5000)
    // , 
    $slidepic.hover(function(){
        clearInterval(timer)
        $(this).find('.toggle').fadeIn();
    },function(){
        clearInterval(timer)
        timer = setInterval(function(){
            fnMove(true)
        },5000)
        $(this).find('.toggle').fadeOut();
    })
})
blockquote,body,button,dd,dl,dt,fieldset,form,h1,h2,h3,h4,h5,h6,hr,input,legend,li,ol,p,pre,td,textarea,th,ul{margin:0;padding:0}
body,button,input,select,textarea{font:12px/1.5 "Microsoft YaHei", " ", SimSun, " ", sans-serif;color: #666;}
ol,ul{list-style:none}
a{text-decoration:none}
fieldset,img{border:0;vertical-align:top;}
a,input,button,select,textarea{outline:none;}
a,button{cursor:pointer;}
.wrap{
    width:1200px;
    margin-left:auto;
    margin-right:auto
}
.slidepic{
    position: relative;
    height: 500px;
}
.slidepic ul{
    position: absolute;
    left:0;
    top:0;
    z-index: 1;
}
.slidepic li{
    position: absolute;
    width: 800px;
    height: 500px;
    left:200px;
    top:0;
    background-color: #6475ae;
}
.slidepic img{
    width: 100%;
    height: 100%;
}
.toggle{
    position: absolute;
    z-index:10;
    width: 100%;
    height: 100%;
    display: none;
}
.toggle a{
    position: absolute;
    left:100px;
    top:50%;
    width: 76px;
    height: 112px;
    margin-top: -56px;
    background:url(../img/prev.png) 0 0 no-repeat;
}
.toggle .next{
    right: 100px;
    left: auto;
    background-image:url(../img/next.png);
}

좋은 웹페이지 즐겨찾기