Is there a good way to do color cycling in javascr

2020-07-18 08:49发布

Here's what I'd like to do: I've got a line of text in an HTML page. I'd like to have that piece of text start at a given color, cycle though the spectrum, wait a second or two, and then repeat.

I'd like to do this in javascript if possible (something like flash isn't totally out of the question, but would be some major scope creep of this project.)

I know enough JS to know this is possible, but that's about it. Can anyone point me in the right direction?

And yes, this is a real client request. I'm just glad they didn't also ask for the blink tag. ;)

3条回答
相关推荐>>
2楼-- · 2020-07-18 09:29

I would look at some of the "fading" javascript examples on the web, and modifying them to loop with the right colors. Here's one example from the web that you could probably modify to cycle constantly.

查看更多
趁早两清
3楼-- · 2020-07-18 09:29

After browsing some of the "fading" examples, we ended up going with jQuery's .animate() function and this color animation plugin. Works spectacularly.

查看更多
家丑人穷心不美
4楼-- · 2020-07-18 09:48

If you want to cycle through the spectrum, using the HSB color model is your best bet.

Related questions:

查看更多
登录 后发表回答