簡體   English   中英

jQuery懸停與動畫然后動畫留在第二個處理程序問題?

[英]jQuery hover with animate then animate left in second handler issue?

我似乎無法想出這個小問題。 當我用類.nav_button將鼠標懸停在div之外時,不透明度會發生變化,但是從底部向上移動15px的按鈕似乎沒有在第二個處理程序中生效?

JS:

$(document).ready( function(){
    $('.nav_button').hover( 
    function(){
    $(this).animate({top:'15px',opacity:'0.5'},'slow')
    },
    function(){
    $(this).animate({bottom:'15px',opacity:'1'},'slow')
    });
});

CSS:

.nav_button{
    height:80px;
    width:90px;
    margin-right:3px;
    border-radius:5px;
    border:2px solid #555879;
    background-color:#2182c2;
    display:inline-block;
    position:relative;

}

像這樣? 演示http://jsfiddle.net/yeyene/kNts8/

JQUERY

$(document).ready( function(){
    $('.nav_button').hover( 
    function(){
    $(this).stop().animate({top:'-15px',opacity:'0.5'},'slow')
    },
    function(){
    $(this).stop().animate({top:'15px',opacity:'1'},'slow')
    });
});

CSS

.nav_button{
    background:red;
    position:relative;
    top:0px;
    padding:0 5px;
    z-index:100;
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM