Why doesn't my keyframe animation for link color work in Chrome?

倖福魔咒の 提交于 2019-12-19 19:49:02

问题


Using @keyframes (and animation) to animate a color does not work in Chrome.

Demo: https://jsfiddle.net/ed3pypwr/
In Chrome the link stays blue. In Firefox it goes from red to green as expected. On a div it works fine in Chrome as well.

Is there any way to solve this?

EDIT
I know it should be prefixed with -webkit- to ensure maximum compatibility, but this is not the issue here. It does not work anyway.

EDIT 2
A solution would be to put the link in a wrapper and use currentColor: https://jsfiddle.net/b84gttu6/. Is there a better way ?


回答1:


Old versions (<43) of Chrome use the prefixed @-webkit-keyframes instead of the standard @keyframes. So full support would look like this:

@-webkit-keyframes test
{
   from { color: red; }
   to { color: green; }
}
@keyframes test
{
   from { color: red; }
   to { color: green; }
}

Update:

I've been doing some tests with various different methods and it works only if the link has not been visited (why, I don't know).

Example



来源:https://stackoverflow.com/questions/30985933/why-doesnt-my-keyframe-animation-for-link-color-work-in-chrome

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!