jQuery plugin to animate colors from one class to another

好久不见. 提交于 2019-12-11 06:42:59

问题


There are a lot of jQuery color plugins. However I couldn't find the one to animate between css class declarations.

For example doing a smooth animation from .class1 to .class2:

.class1 { background-color: #000000 }
.class2 { background-color: #000088 }

Is this possible at all?


回答1:


The jQuery animate() command already allows you to animate colour transitions.

Here's a more striking demo

EDIT:

To get the same effect with CSS classes, there is

  • jQuery UI's switchClass(add, remove, duration)

  • Igor Vieira's animateToClass plugin

  • James Padolsey's animateToSelector plugin




回答2:


I think a plugin can be done that will read all computed properties of class A, match them with the properties of class B, animate what it can be animated, and ignore the rest of properties.

I have not seen no one out there but it can be done.



来源:https://stackoverflow.com/questions/1592990/jquery-plugin-to-animate-colors-from-one-class-to-another

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!