我的代碼,這一點可以在行動中可以看出這裏擴大DIV與jQuery
http://jsfiddle.net/rullingen/GCXsq/1/
上空盤旋時和合同時沒有這基本上擴展一個div高度。 目前它從75px擴展到300px。我想改變它,以便它從75px擴展到適合DIV內部內容的高度。我曾嘗試將擴展值設置爲「自動」,但這似乎不起作用。任何人都可以給我一個指針嗎?
HTML
<div class="expand">
<img src="http://rauanklassnikringing.com/wp-content/uploads/2010/11/carrot-imperator.jpg" alt="" />
</div>
<div class="expand">
<img src="http://rauanklassnikringing.com/wp-content/uploads/2010/11/carrot-imperator.jpg" alt="" />
</div>
<div class="expand">
<img src="http://rauanklassnikringing.com/wp-content/uploads/2010/11/carrot-imperator.jpg" alt="" />
</div>
<div class="expand">
<img src="http://rauanklassnikringing.com/wp-content/uploads/2010/11/carrot-imperator.jpg" alt="" />
</div>
<div class="expand">
<img src="http://rauanklassnikringing.com/wp-content/uploads/2010/11/carrot-imperator.jpg" alt="" />
</div>
的Javascript
$('.expand').hover(function() {
$(this).animate({
height: '300px'
}, 300);
},function() {
$(this).animate({
height: '75px'
}, 300);
});
CSS
.expand {
overflow: hidden;
margin-bottom: 15px;
height: 75px;
}
非常有幫助,非常感謝。 – 2011-02-16 09:44:48