2013-03-04 60 views
0

是否有替代jquery slideDown()的已知?替代jQuery .slideDown()

我問的原因是,我認爲slideDown應該真正的名字滾下來,因爲它類似於解開內容,而不是實際滑落下來。

這是我的意思是效果的例子 - 鼠標懸停在頁面上的主要項目之一(不工作在IE):Example slide down

理想需要在IE中工作過,所以我猜這是比js更多的過渡,當ie10上的每個人都需要一段時間時,這是可以的!

+0

我不能讓你的問題。你只是在抱怨函數的名字,即語義嗎? – Alexander 2013-03-04 13:52:50

+0

您可以使用方便的'.animate()'方法創建自己的變體。 – Boaz 2013-03-04 13:53:14

+1

好像你只是想嘗試像這樣[** FIDDLE **](http://jsfiddle.net/adeneo/U7AxG/)? – adeneo 2013-03-04 14:05:12

回答

1

我會做到這一點的方式是把我的容器相對定位和隱藏的溢出; 然後讓我將鼠標懸停在絕對位置上,頂部爲-50px,然後使用jquery動畫將其懸停下移。

An example is here

<div class="container"> 
    <div class="hover"></div> 
</div> 

.container{width:400px;height:400px; border:1px solid grey; position:relative;overflow:hidden;} 
.hover{position:absolute;top:-50px; width:100%;height:50px; background-color:red;} 

$('.container').hover(function() { 
    $('.hover').animate({ 
     top: '+=50' 
    }); 
},function(){ 
    $('.hover').animate({ 
     top: '-=50' 
    }); 

}); 
3

有了更多的代碼,你可以使用.animate()

編號:

一個小例子:

$(document).ready(function(){ 
    $(element).toggle(function(){ 
    $(this).animate({height:40},200); 
    },function(){ 
    $(this).animate({height:10},200); 
    }); 
});