Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS Animating SVG with CSS Keyframe and Line Drawing Animations Finishing the Animation Sequence

Jacob Brech
Jacob Brech
7,224 Points

Question about the delay property used in animation

I have a question about the delay property. If we consider the following example:

.star circle { animation: pulse .7s 1.5s; }

.star circle:nth-of-type(2) { animation-delay: 1.6s; }

.star circle:nth-of-type(3) { animation-delay: 1.7s; }

What will be the actual delay here?

.star circle has already a delay of 1.5s, but then we target individual circles as well with nth-of-type, what will the delay be for i.e .star circle:nth-of-type(2)? Will it be 1.5s+1.6s = 3.1s? Or will the delay only be 1.6s?

Thanks in advance

2 Answers

Hey Jacob, the delays for the animations only apply to the assigned element, what they do is they all start the delays at the same time, and run at their respective delay time. So an element with 1.6s delay and an element with a 1.8s delay will start their "stopwatches" at the same time then run after their assigned delay is up. Hope this helps!

What happens is that all the circle elements within .star first get an animation-delay of 1.5s. Then, each circle element gets their own individual animation-delay because we explicitly overwritten them individually. The first circle is the only one to retain the initial animation-delay of 1.5s because we did not overwrite its value.

So to answer the question, the delay for .star circle:nth-of-type(2) will be 1.6 because we overwritten the initial value.