我是Jquery的業餘愛好者,但我非常接近獲取我所需要的東西。我試圖讓一個包含div的元素在點擊對象時具有更大的高度。我使用下面的代碼:使用JQuery來動畫Div的大小
<div id="sliderone">
<div id="nav">
<div id="navone" style="text-align: center;">This is a clickable title</div>
</div>
<div id="ourteam">
<div id="title"></div>
</div>
</div>
<script type="text/javascript">
$('#navone').click(function(){
$('#title').html("<img src='http://placehold.it/350x550' alt='' />");
$('.post-8 .content-container').animate({height: '950'});
});
</script>
#navone {
padding:20px 20px;
cursor:pointer;
}
#title {
width:350px;
margin:0 auto;
}
#sliderone {
height:50px;
background-color:#777777;
position: absolute;
margin-top: -500px;
left: 50%;
margin-left: -175px;
}
#sliderone
必須絕對定位,所以當我嘗試動畫.post-8 .content-container
它使上邊長的比較,而不是使底邊長爲包含新的內容。我可以動畫縮小負邊距還是動畫底部的.post-8 .content-container
?
謝謝你的幫助。我在這方面努力工作,只是無法弄清楚最後一個問題。
下面是實際看到的頁面。
http://s416809079.onlinehome.us/wp-login 登錄:計算器 密碼:計算器
這裏看看http://www.w3schools.com/jquery/jquery_animate.asp – user2167382
什麼關於使用jQuery庫中的'slideDown'? –
您正在使用jQuery的類選擇器,但這些類不存在於html中。你的選擇器不會選擇任何東西,因此不會動畫。 – Bic