对于我的生活,我无法弄清楚这一点,我试图将div设置为其自然高度的动画,但是jquery只能让我降低价值。我想根据内容的数量自动调整大小......我遇到问题的代码中的行是:
$ elem.addClass('current')。animate({height:'100'},300);
我希望100是自动的。请帮助!
以下是代码:
$list.find('.st_arrow_down').live('click',function(){
var $this = $(this);
hideThumbs();
$this.addClass('st_arrow_up').removeClass('st_arrow_down');
var $elem = $this.closest('li');
var $plus = $this.closest('li').height();
$elem.addClass('current').animate({height: '100'},300);
var $thumbs_wrapper = $this.parent().next();
$thumbs_wrapper.show(200);
});
$list.find('.st_arrow_up').live('click',function(){
var $this = $(this);
$this.addClass('st_arrow_down').removeClass('st_arrow_up');
hideThumbs();
});
答案 0 :(得分:0)
你的意思是计算高度?
$elem.addClass('current').animate({height: $elem.height()},300);
如果您使用CSS为$ elem设置固定高度,则无效。
答案 1 :(得分:0)
我看到的唯一可能是克隆节点(移除固定高度),将其放置在屏幕外的某处,并进行测量。