简体   繁体   English

如何很好地将前置项滑到列表中

[英]How to nicely slide down a prepended item to a list

similar to twitter's ux, I want to prepend a feed item to a list and have it SlideDown on entry. 类似于twitter的ux,我想将供稿项添加到列表中,并使其在输入时具有SlideDown。

Here's my attempt here: http://jsfiddle.net/26jaw/9/ 这是我在这里的尝试: http : //jsfiddle.net/26jaw/9/

What I've learned so far is that for the slideDown to work the height needs to be set, min-height doesn't work. 到目前为止,我了解到,要使slideDown正常工作,需要设置高度,而min-height不起作用。 So given that the feed item height is variable, I find the height after injecting it in the page. 因此,鉴于Feed项的高度是可变的,因此我将其注入页面后便找到了高度。 I then set the height, and slideDown. 然后,我设置高度,并设置slideDown。 but for some reason that isn't working as you can see in the jsfiddle. 但是由于某种原因,您无法在jsfiddle中看到它的作用。 The height being reported by jQuery is invalid and the height is wrong resulting in text being cut off. jQuery报告的高度无效并且高度错误导致文本被截断。

Any ideas? 有任何想法吗? Better solutions? 更好的解决方案? Thanks 谢谢

Remove this declaration from the CSS rule #feedlist {} : 从CSS规则#feedlist {}删除此声明:

height: 600px;

Then change your JavaScript to: 然后将您的JavaScript更改为:

item = $(content).prependTo("#feedList");
height = item.height();
item.hide();
item.css("height", height).slideDown();

See updated fiddle . 参见更新的小提琴

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM