我看到了一個小提琴。當光標懸停在它上面時,它從下到上進行動畫處理。如何從右向左滑動使用div顯示內容
我該如何改變它,以便在點擊時,它會從右到左進行動畫製作,然後,內容會被隱藏起來?當內容被隱藏時,會出現一個按鈕,我可以點擊該按鈕讓內容再次顯示。
HTML
<html>
<body>
<div class="wrapper">
<div class="inner">
Sliding div here!! Yay!!
</div>
</div>
<p>Hover over red div please!!</p>
</body>
</html>
CSS
.wrapper{
background-color:red;
width:200px;
height:200px;
position:relative;
overflow:hidden;
color:white;
}
.inner{
width:200px;
height:100px;
position:absolute;
background-color:black;
margin-top:200px;
color:white;
}
jQuery的
$(document).ready(function(){
var innerHeigth = $(".inner").outerHeight();
$(".wrapper").hover(function(){ $(".inner").stop().animate({top:-innerHeigth},1000);
//alert(innerHeigth)
},function(){
$(".inner").stop().animate({top:0},1000);
});
});
,這裏是小提琴http://jsfiddle.net/qGVfp/
這個點擊是怎麼樣的,點擊顯示並再次點擊隱藏 – 2013-02-13 05:03:00
@FrancisAlvinTan我更新了我的答案,它現在點擊切換。 – 2013-02-13 14:04:32