如何使文字慢慢改变悬停的颜色

How to make text slowly change color on hover?

本文关键字:悬停 颜色 改变 慢慢 何使 文字      更新时间:2023-09-26

我想让我的文字慢慢改变颜色,像这样:http://trentwalton.com/2011/05/10/fit-to-scale/

任何想法?

工作小提琴演示

你可以使用CSS过渡:

a {
    color: lime;
    -webkit-transition: color 1s;
    -moz-transition:    color 1s;
    -ms-transition:     color 1s;
    -o-transition:      color 1s;
    transition:         color 1s;
}
a:hover {
    color: red;
}

使用CSS过渡。参见:Fiddle

a {
  color: #000000;
}
a:hover {
   color: #E24B3B;
}
ul a {
 -webkit-transition: color 0.2s ease-out;
 -moz-transition: color 0.2s ease-out;
 -o-transition: color 0.2s ease-out;
 -ms-transition: color 0.2s ease-out;
 transition: color 0.2s ease-out;
 }

正如@ elclars所说,或者你也可以使用这个

$("selector").hover(function(){
    // your code to fade in or fade out ....
});

Try

a {
  color: red;
-webkit-transition: color 0.2s ease-out;
 -moz-transition: color 0.2s ease-out;
 -o-transition: color 0.2s ease-out;
 -ms-transition: color 0.2s ease-out;
 transition: color 0.2s ease-out;
}
a:hover {
   color: blue;
}