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

Kai Barnes
Kai Barnes
15,684 Points

Problem with SVG animation challenge

I am on the challenge at the end of the Animating SVG with CSS course. I am trying to animate the stars, and somehow ended up with the stars moving to the side, even when I am translating them on the Y axis. I checked the solution video, and I can't find any differences between the code that would cause this. This is all I have so far

/* --------------------------
  Base
--------------------------- */

body {
  padding-top: 60px;
    background: #0f4e7a;
}

svg {
    margin: auto;
  display: block;
    width: 28%;
}

/* --------------------------
  Keyframes
--------------------------- */

@keyframe slide{
  50%{
    transform: translate3d(0,-10px,0);
  }
  60%{
    transform: translate3d(0,10px,0);
  }
}

/* --------------------------
  SVG Styles
--------------------------- */
.stars *{
 transform-origin: 50% 50%; 
}

.star{
 transform: translate3d(0,200px,0);
 animation: slide 1s ease; 
}

1 Answer

Steven Parker
Steven Parker
229,952 Points

Here's one issue:

You'll probably want to make other changes also, but I noticed on line 20 you wrote "keyframe" (singular) instead of "keyframes". Fixing that should get you going on the rest.

Also, for sharing code with multiple files, you may want to use the snapshot function in the workspace and provide the link to that.

Kai Barnes
Kai Barnes
15,684 Points

Oh wow, I can't believe I missed that. Thanks a lot.

I see. It's my first time hearing of that function. I will use it in the future. Thank you.