jquery实现随机颜色_jQuery随机链接颜色动画

叁歲伎倆 2023-02-22 01:24 124阅读 0赞

jquery实现随机颜色

We all know that we can set a link’s :hover color, but what if we want to add a bit more dynamism and flair? jQuery allows you to not only animate to a specified color, but also allows you to animate to a random color.

大家都知道我们可以设置链接的:hover颜色,但是如果我们想增加一点动感和个性呢? jQuery不仅允许您将动画设置为指定的颜色,还允许您将动画设置为随机的颜色。

View Demo 观看演示

jQuery JavaScript (The jQuery JavaScript)

  1. $(document).ready(function() {
  2. var randomLinks = $('a.random-color');
  3. var original = randomLinks.css('color');
  4. randomLinks.hover(function() { //mouseover
  5. var col = 'rgb(' + (Math.floor(Math.random() * 256)) + ',' + (Math.floor(Math.random() * 256)) + ',' + (Math.floor(Math.random() * 256)) + ')';
  6. $(this).animate({
  7. 'color': col,
  8. 'paddingLeft': '20px'
  9. },1000);
  10. },function() { //mouseout
  11. $(this).animate({
  12. 'color': original,
  13. 'paddingLeft': '0'
  14. },500);
  15. });
  16. });

View Demo 观看演示

For the color animation portion, you’ll need an extra Color Animations jQuery plugin. The padding nudge is another neat effect. This effect isn’t for everyone, but it can add another subtle effect to your jQuery-enabled website.

对于彩色动画部分,您将需要一个额外的Color Animations jQuery插件。 填充微调是另一个很好的效果。 这种效果并不适合所有人,但可以为启用jQuery的网站添加另一种微妙的效果。

翻译自: https://davidwalsh.name/jquery-random-color-animate

jquery实现随机颜色

发表评论

表情:
评论列表 (有 0 条评论,124人围观)

还没有评论,来说两句吧...

相关阅读

    相关 Flutter 随机颜色 颜色处理工具类

    > 在码农的世界里,优美的应用体验,来源于程序员对细节的处理以及自我要求的境界,年轻人也是忙忙碌碌的码农中一员,每天、每周,都会留下一些脚印,就是这些创作的内容,有一种执着,就

    相关 随机颜色

    随机颜色 开发工具与关键技术:JavaScript 作者:陈希雄 撰写时间:2019/2/19 提醒:其实也可以拼接成自己想要的图形或者文字 操