Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

css3 Transition delay if animate svg fill and color at the same time bug in chrome works in FF

i have a link with an inline svg and a text. I want to animate on :hover (or add an .active class), but on Chrome the transition isn't happening at the same time. On Firefox everything is working perfect. Here is the demo:

[DEMO](http://codepen.io/anon/pen/QNvgvy)

Is there somebody who knows a solution for this problem? Thank you!

like image 804
tompagabor Avatar asked Mar 23 '16 14:03

tompagabor


People also ask

Which delay CSS property is used for transition effect?

The transition-delay property specifies when the transition effect will start. The transition-delay value is defined in seconds (s) or milliseconds (ms).

Why is transition property not working?

The reason for this is, display:none property is used for removing block and display:block property is used for displaying block. A block cannot be partly displayed. Either it is available or unavailable. That is why the transition property does not work.

How do I delay an animation in CSS?

The CSS animation-delay property has the following syntax: animation-delay: [time] | initial | inherit; As you can see, there are three possible values: time, initial, and inherit. The first option is [time], which is the number of seconds or milliseconds before the animation starts.

How do I set transition time in CSS?

CSS Transition-Property Here's an example of the syntax: transition-duration: 1s; transition-property: background, color; This will make the background and color transition in 1 second, but nothing else will be transitioned.


1 Answers

I guess what happens here is the difference between FF and Chrome in the way inherited css is propagated during transition phase. FF does so immediately, while Chrome applies new style value to a child element only when transition on parent is finished.

Take a look at this example: https://jsbin.com/koruyeludi/1/edit?html,css,js,console,output and keep an eye on color values printed in console when you hover.

Example has 2 spans, .child is nested within .parent. Both have transition applied to them. When you hover over parent span, color is changed gradually. Once transition is done on parent, color is changed on child node. And since it has transition as well it comes into play now.

So in your example you have * { transition: all 1s; }. Parent <a> will be in color transition during [0s-1s] interval. <span> and <svg> will be changing their color during [1s-2s]. And <path> will be making a change in [2s-3s]. To avoid that, apply transition: only once - on root <a> element).

like image 115
Max Ivanov Avatar answered Nov 15 '22 08:11

Max Ivanov