我如何“持有” jQuery 下的元素反弹?
jQuery 的效果很棒,但我注意到受影响元素下的剩余元素由于包装 div 的原因而发生了移位(访问此演示页面并滚动到“弹跳效果”或“摇动效果”即可查看)。
在播放效果时如何保持文档中的其余元素稳定?
jQuery's effects are great, but I've noticed that the remaining elements under the affected element are displaced because of the wrapping divs which cause the effect (visit this demo page and scroll to "The Bouncing Effect" or "The Shake Effect" to see).
How do I hold the rest of the elements in the document steady while the effect plays?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,区别在于:如果您尝试直接为锚点等元素设置动画,最终会影响其他流程。如果您将相同的元素包装在 div 中并进行动画处理,那就没问题了。看看jsfiddle.net/ejwh4/4和jsfiddle.net/ejwh4/5的区别
Okay, here's the difference: if you try to animate an element like an anchor DIRECTLY, you end up affecting other flow. If you wrap that same element in a div and animate, it's fine. Look at the difference between jsfiddle.net/ejwh4/4 and jsfiddle.net/ejwh4/5
你举的例子并不是最好的。该效果只会移动您指定的元素。
正如您在此处看到的,另一个元素不受该效果的影响。
然而,您所拍摄的演示中发生的问题有时可能会发生,您必须小心。
该问题可能是由位置不当的元素和动画引起的。如果一个元素 (A) 的位置取决于动画元素 (B) 的位置,则如果 B 移动,A 也会以某种方式移动。
The exemple you took is not the best. The effect only moves the element you tell it to.
As you can see here the other element is not affected by the effect.
However the problem that is happening in the demo you took could happen sometimes and you must be carefull.
The problem could be caused by poorly positioned elements and animations. If the position of one element (A) depends on the position of an animated element (B), if B moves A will move too somehow.