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 The Animation Challenge Solution

Sharing my solution

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

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

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

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

@keyframes rise {
 0% {
    transform:translateY(300%)
  }

  30% {
    transform:translateY(-10%);
  }

  60% {
     transform:translateY(20%);
  }
}

@keyframes rotate {
 0% {
    transform: scale(1);
  }
 50% {
    transform: rotate(-5deg) scale(1.15);
    opacity: 1;
    fill: #FFDF00;
  }
  100% {
   transform: scale(1);
  }
}

@keyframes offset { 

 0% {
    stroke-opacity: 0;
  }

 30% {
    stroke-opacity: .8;
  }

 100% {
   stroke-dashoffset: 0; 
   stroke-opacity: 0;
  }
}


/* --------------------------
  SVG Styles
--------------------------- */

.stars * {
  transform-origin: 50% 50%;
  transform-box: fill-box;
}

.star:nth-of-type(2) {
  animation: rise .5s .25s linear backwards,
             rotate .6s 1s ease-in-out;
}

.star:nth-of-type(1) {
  animation: rise .5s .55s linear backwards,
             rotate .6s 1.3s ease-in-out;
}

.star:nth-of-type(3) {
  animation: rise .5s .88s linear backwards,
             rotate .6s 1.6s ease-in-out;
}

.stars-bg {
  stroke-opacity: 0;
  stroke-width: 7;
  stroke-dasharray: 810;
  stroke-dashoffset: 810;

  animation: offset .8s 2s linear backwards;
}

1 Answer