作者:liuc | 来源:互联网 | 2023-08-10 16:10
IsitpossibletochangethecolorofadivonhoverforXseconds,thenreturntoitsoriginalcolo
Is it possible to change the color of a div on hover for X seconds, then return to its original color using only CSS?
是否可以将div的颜色在悬停状态下更改X秒,然后仅使用CSS返回到原来的颜色?
I do not want any fade ins or outs between the color. For example, if I want to change the color of the div to yellow for 1 second on hover, it must remain yellow for 1 second, then immediately return to the original color.
我不希望在颜色之间有任何褪色。例如,如果我想在鼠标悬停1秒时将div的颜色更改为黄色,那么它必须保持黄色1秒,然后立即返回原始颜色。
This (http://jsfiddle.net/hZ49y/1/) is what I have so far. It works as I described above, but I feel that this way of using animation
is not intuitive and hard to understand. Should I stick to using Javascript for this purpose? What are some alternatives?
这个(http://jsfiddle.net/hZ49y/1/)是我目前所拥有的。它就像我上面描述的那样工作,但是我觉得这种使用动画的方式不是直观的,很难理解。我应该坚持使用Javascript实现这个目的吗?有哪些选择呢?
3 个解决方案