2012-11-15 77 views
0

有沒有辦法讓jQuery的div高度動起來,讓div的頂部和底部都展開?我想在LDS主頁上做一些事情:www.lds.org。頂部橫幅圖像左側的div是我要去的東西的類型。jQuery特殊的div高度動畫

回答

0

您可以通過向上移動div並在動畫顯示高度時創建向上和向下方向擴展的幻覺。

<html> 

<head> 
<script type="text/javascript" src="jquery-1.8.0.min.js"></script> 
<script> 
$(document).ready(function() { 
    var d = $('div'); 
    d.css('top', '250px').css('height', 0); 
    d.animate({ 
     height: '500px', 
     top: 0 
    } , 3000); 
}); 
</script> 
<style> 
div { 
    width: 500px; 
    height: 500px; 
    background: #f00; 
    position: absolute; 
} 
</style> 
</head> 

<body> 
<div></div> 
</body> 

</html> 
+0

謝謝!你能告訴我爲什麼這個職位必須被宣佈爲絕對的嗎? – MRichards