jQuery slideDown不平滑 [英] jQuery slideDown is not smooth

查看:164
本文介绍了jQuery slideDown不平滑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个小小的jQuery slideDown效果 http://jsfiddle.net/Gg4eP/2/

但动画不流畅?我做错了什么?



感谢您的时间。

>您只需将宽度添加到每个可展开的div。



http://jsfiddle.net/BpMam/



解释:

jQuery doesn'不知道隐藏div的大小,直到显示出来。所以当它被点击时,它实际上会将它拉出来以便在快速替换它之前进行测量。这往往有导致一些跳跃的副作用。设置元素的宽度可以防止jQuery将它拉出来。


I have this little jQuery slideDown effect http://jsfiddle.net/Gg4eP/2/

But the animation isn't smooth? What I am doing wrong?

Thanks for your time.

解决方案

You just need to add the width to each expandable div.

http://jsfiddle.net/BpMam/

To explain:

jQuery doesn't know the dimensions of your hidden div until it's displayed. So when it's clicked on it actually pulls it out of position to measure it before quickly replacing it. This often has the side effect of causing some jumpiness. Setting the width on the element prevents jQuery from pulling it out of position.

这篇关于jQuery slideDown不平滑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆