有没有办法在悬停时平滑地设置文本颜色的动画?

Kat*_*rne 1 javascript css

我正在使用的设计包括一个按钮悬停,用颜色填充按钮.这是在初始状态下与填充颜色相同的文本.随着填充的进行,文本的颜色变为对比色,但是平滑.以下是设计师给我的一段视频,说明了这个问题:

在此输入图像描述

你可以在字母'a'上看到它是两种不同的颜色.所以我无法逐字母地改变文本的颜色.

有没有任何方法(JS/Jquery/whatever/CSS)来实现这个目的?我想不是,但也许有一些方法可以在整个文本中设置一个尖锐的渐变动画?我不知道.

Ser*_*ata 9

实际上我刚才为另一个问题做过类似的事情.

这可以通过实现mix-blend-mode.我也减慢了时间,5s以便你可以清楚地看到它是如何工作的.0.25s在使用时将其更改为满足您需求的任何内容.

a {
  position: relative;
  text-decoration: none;
  display: inline-block;
  padding: 15px 30px;
  border: 3px solid #f16251;
  background: white;
  color: black;
  font-size: 30px;
  font-family: arial;
  mix-blend-mode: normal;
  overflow:hidden;
  z-index: 1;
}

a:before {
  content: '';
  position: absolute;
  top: 0; bottom: 0; right: 0;
  width: 100%; height: 100%;
  background: white;
  mix-blend-mode: difference;
  transform-origin:0 0 ;
  transform:translateX(100%);
  transition: transform 5s;
  z-index: 3;
}
a:hover:before {
  transform: translateX(0);
}

a:after{
  content: '';
  display:block;
  top: 0;
  left:0;
  bottom:0;
  right:0;
  position: absolute;
  z-index: 100;
  background: #f16251;
  mix-blend-mode: screen;
}
Run Code Online (Sandbox Code Playgroud)
<a href="#" class="btn">WoOoOoOoT</a>
Run Code Online (Sandbox Code Playgroud)