CSS3 color transition not working in Chrome

对着背影说爱祢 提交于 2019-11-28 22:53:40

@Nijikokun I can confirm the same thing. :visited links do not transition correctly in Chrome. Hooray. It seems like this is an issue that cropped up in version 16 and never got fixed. There are a few bug reports open on the Chromium site.

http://code.google.com/p/chromium/issues/detail?id=101245&q=visited%20transition&colspec=ID%20Pri%20Mstone%20ReleaseBlock%20Area%20Feature%20Status%20Owner%20Summary

I tried to find a workaround (more details in my blog: http://kyuumeitai.posterous.com/the-case-of-the-chromes-transition-hover-bug)

It seems if you declare a:visited with color (color, background, border-color, etc) transparent it will work as a workaround. I haven't tested extensivelly yet, glad to receive feedback.

This is not a -non- working issue, what it is is the :visited link is not transitioning, so it may work for you if you have not clicked on it, but if you have, it will not.

I do not know a solution, I am still looking for one...

. . I thought it would be nice to notice that this it not a bug, but intended behavior. Quoting the Mozilla Developer docs:

Impact on web developers

Overall, this shouldn't affect web developers too significantly. There are, however, a few special cases that may require changes to sites:

(...)

CSS transitions won't be supported for visited links. Fortunately, CSS transitions are very new, and there are few sites using them at this point, so this isn't likely to impact many people at this point.

Burnee

As Darren Kovalchik wrote in his asnwer ( https://stackoverflow.com/a/8524199/1010777 ), the Chrome has a bug on this.

A possible workaround is to apply color animation on the parent element of the link, and set the link's color to inherit. In this case the animation works well even if the link is :visited.

html:

<span class="whateverLinkParent">
    <a href="#">whateverLinkText</a>
</span>

css:

.whateverLinkParent { animation: whateverTextColorAnimation 1s infinite; }
.whateverLinkParent a { color: inherit; }
@keyframes whateverTextColorAnimation {
    0%, 100% { color: #686765; }
    50% { color: #2E2D2B; }
}

Of course this workaround can't work if setting the link's parent's color is a problem, but in every other cases it gives an easy and clean solution.

Try using #ccc and #000 rather than gray and black.

edit: Like so: http://jsfiddle.net/qtzEj/

Hope that helps :)

Two of my link transition work, but the rest doesnt in chrome. They all use the same setting. It seems they work when the link is either mailto: or callto: -- oddly strange if you ask me.

If you remove color from :visited behavior then it should work as expected. When color is set in :visited behavior, even :hover color (without transition) does not work as expected.

I still ran into the same issue and found a solution that worked for me.

I was able to fix it by using the :link pseudo class like this:

#menu a, #menu a:link {
  color: gray;
  transition: color 0.5s;
}

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