You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

移除渐变文本hover样式,实现鼠标悬停时文本变蓝色的方案

渐变文字hover切换蓝色失效的解决办法

问题根源在于你给span设置了-webkit-text-fill-color: transparent,这个属性优先级高于color,所以hover时的color: blue无法覆盖透明填充,自然看不到蓝色效果。

修改后的CSS代码如下:

span {
  font-size: 40px;
  font-weight: 600;
  text-align: center;
  background: -webkit-linear-gradient(90deg, rgba(0, 255, 19, 1) 0%, rgba(0, 209, 255, 1) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  cursor: pointer;
  transition: all 500ms ease;
}

span:hover {
  background: none;
  -webkit-text-fill-color: blue;
  color: blue;
}

关键修改点:

  • hover状态下移除渐变背景,避免和文字颜色冲突
  • 用-webkit-text-fill-color: blue直接覆盖初始的透明设置,同时保留color: blue做跨浏览器兼容
  • 优化过渡属性为all 500ms ease,让颜色切换更平滑(也可以保留原有的transition: 500ms)

内容的提问来源于stack exchange,提问作者Vans

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.07 08:22:47