Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                svg.spaceship(xmlns='http://www.w3.org/2000/svg', viewbox='0 0 109.3 116.8')
  g#leg-4.leg.leg__4.leg--moving
    path.leg(d='M83.7 99.6l-8.8-13c-.8-1.1-.4-2.7.7-3.4 1.2-.7 2.7-.3 3.3.9L86.4 98c.4.7.1 1.7-.6 2.1-.7.4-1.6.2-2.1-.5z')
    path.leg.leg__4__tip.leg--moving-tip(d='M82.3 107.1l1.8-8.6c.1-.7.8-1.1 1.5-.9.7.2 1.1.9.8 1.5l-2.7 8.4-2 4.7.6-5.1z')
  g#leg-1.leg.leg__1.leg--moving
    path.leg(d='M23.5 99.6l8.8-13c.8-1.1.4-2.7-.7-3.4-1.2-.7-2.7-.3-3.3.9L20.8 98c-.4.7-.1 1.7.6 2.1.7.4 1.6.2 2.1-.5z')
    path.leg.leg__1__tip.leg--moving-tip(d='M24.9 107.1l-1.8-8.6c-.1-.7-.8-1.1-1.5-.9-.7.2-1.1.9-.8 1.5l2.7 8.4 2 4.7-.6-5.1z')
  g#alien
    path#body.st1(d='M63.6 52.4c.3-1.4.1-3.1-.1-4.4-.3-1.8-1.4-1.2-1.9-.7s.2 2 0 3.1c-.1.7-1 1.6-1.5 2.1-7.7 1.2-12.8 10.8-12.8 10.8 5.1.2 14.1 0 20.3 0-.2-5.5.6-10.1-4-10.9z')
    g#head.head
      path.st1(d='M55.9 46.3l-3.1-1.7c-3.3-1.9-2.4-6.9 1.4-7.5l5.6-.9c4.1-.7 8.4.1 12.1 2.2l5.1 2.9c3.3 1.9 2.4 6.9-1.4 7.5l-3.6.6c-5.5.7-11.2-.3-16.1-3.1z')
      circle.st2(cx='54.9', cy='41.2', r='3.1')
      circle.st2(cx='75.1', cy='44.8', r='3.1')
      circle.st3(cx='56.3', cy='40.2', r='.9')
      circle.st3(cx='53.4', cy='42.1', r='.9')
      circle.st3(cx='76.6', cy='43.9', r='.9')
      circle.st3(cx='73.7', cy='45.7', r='.9')
  g#spaceship
    path.st4(d='M37.8 92.6c-7-1.6-14.1-7.6-14.9-11h67S57.7 97 37.8 92.6z')
    path.st5(d='M95.8 82.7l-17 1.2c-16.1 1.2-32.2 1.2-48.2 0l-16.8-1.2c-5.5 0-9.9-4.2-9.9-9.4s4.5-9.4 9.9-9.4h9l4.6.4c18.3 1.7 36.7 1.9 55 .6l13.5-1c5.5 0 9.9 4.2 9.9 9.4s-4.5 9.4-10 9.4z')
    path.st6(d='M77.4 14.1C108 9.3 88.3 56.2 89.2 63.9h-67s21.4-44.5 55.2-49.8z')
    path.st7(d='M102.8 79.8l-9.8.6c-25.6 1.6-51.2 1.6-76.8 0l-9.8-.6c-3.6 0-6.5-2.9-6.5-6.5s2.9-6.5 6.5-6.5l9.8.6C41.8 69 67.4 69 93 67.4l9.8-.6c3.6 0 6.5 2.9 6.5 6.5s-2.9 6.5-6.5 6.5zM82.8 12.5s-.9 1.3-3 .3c-1.7-10.1-1.4-8.9-1.4-8.9L70.1 0l10 2.5 2.7 10z')
    path.st4(d='M21.9 61.2c-1.8 1.8-2.8 2.9-2.8 2.9l12.7 1c15.8 1.3 31.6 1.3 47.4 0L92.4 64c0-.3-.1-.6-.1-.9-.3-1.8-1.8-3-3.6-3l-5.9.5c-18 1.6-36.1 1.6-54-.1l-4.2-.4c-1.1.1-2 .5-2.7 1.1zM82.8 11.4c.9.4 1.7 2.1 1.8 3-1 .6-2.5.8-3.4.8-3.6 0-4.8-.8-4.8-.8s4-4.3 6.4-3z')
    g#lantern_1.lantern_1
      circle.st4(cx='7.3', cy='73.5', r='3.6')
      circle.st8(cx='7.3', cy='73.5', r='2.9')
      circle.st9(cx='8', cy='72.9', r='1.8')
    g#lantern_2.lantern_2
      circle.st4(cx='23.1', cy='74.5', r='3.6')
      circle.st8(cx='23.1', cy='74.5', r='2.9')
      circle.st9(cx='23.8', cy='73.9', r='1.8')
    g#lantern_3.lantern_3
      circle.st4(cx='38.9', cy='75.5', r='3.6')
      circle.st8(cx='38.9', cy='75.5', r='2.9')
      circle.st9(cx='39.6', cy='74.9', r='1.8')
    g#lantern_4.lantern_4
      circle.st4(cx='54.7', cy='75.5', r='3.6')
      circle.st8(cx='54.7', cy='75.5', r='2.9')
      circle.st9(cx='55.4', cy='74.9', r='1.8')
    g#lantern_5.lantern_5
      circle.st4(cx='70.6', cy='75.5', r='3.6')
      circle.st8(cx='70.6', cy='75.5', r='2.9')
      circle.st9(cx='71.2', cy='74.9', r='1.8')
    g#lantern_6.lantern_6
      circle.st4(cx='86.4', cy='74.5', r='3.6')
      circle.st8(cx='86.4', cy='74.5', r='2.9')
      circle.st9(cx='87', cy='73.9', r='1.8')
    g#lantern_7.lantern_7
      circle.st4(cx='102.2', cy='73.5', r='3.6')
      circle.st8(cx='102.2', cy='73.5', r='2.9')
      circle.st9(cx='102.9', cy='72.9', r='1.8')
    path.st6(d='M87.4 23.2c-1.2 0-2.2-1-2.2-2.2 0-1.2 1-2.2 2.2-2.2 1.2 0 2.2 1 2.2 2.2 0 1.2-1 2.2-2.2 2.2zM89.1 26.1c.8-.3 1.6.2 1.6 1.1 0 7.5-.6 14.3-3.3 22.2.9-9.8 1.7-14.9 1-22-.1-.6.2-1.1.7-1.3z')
  g#leg-3.leg.leg__3.leg--moving
    path.leg(d='M70.8 104.2l-8.8-13c-.8-1.1-.4-2.7.7-3.4 1.2-.7 2.7-.3 3.3.9l7.5 13.8c.4.7.1 1.7-.6 2.1-.7.5-1.6.3-2.1-.4z')
    path.leg.leg__3__tip.leg--moving-tip(d='M69.4 111.7l1.8-8.6c.1-.7.8-1.1 1.5-.9.7.2 1.1.9.8 1.5l-2.7 8.4-2 4.7.6-5.1z')
  g#leg-2.leg.leg__2.leg--moving
    path.leg(d='M32.2 104.2l8.8-13c.8-1.1.4-2.7-.7-3.4-1.2-.7-2.7-.3-3.3.9l-7.5 13.8c-.4.7-.1 1.7.6 2.1.7.5 1.6.3 2.1-.4z')
    path.leg.leg__2__tip.leg--moving-tip(d='M33.6 111.7l-1.8-8.6c-.1-.7-.8-1.1-1.5-.9-.7.2-1.1.9-.8 1.5l2.7 8.4 2 4.7-.6-5.1z')
    
.background
  .sky   
    each i in new Array(3)
      .cloud
  .city
              
            
!

CSS

              
                @import "bourbon";

$main-color: #4db858;
$background-color: #03293a;



@keyframes light {
  from { fill: adjust-hue(lighten($main-color, 0%), 0deg)}
  to { fill: adjust-hue(lighten($main-color, 30%), 90deg)}
}


@keyframes rotate {
    from { @include transform(rotate(0deg)) }
    to { @include transform(rotate(30deg))}
}

@keyframes head-nod {
    from { transform: rotate(-20deg) }
    to { transform: rotate(10deg) }
}

@keyframes background-scroll {
  from { background-position: 0vw }
  to { background-position: -100vw }
}

@keyframes float {
    0% {transform: translate(0px, 0px) rotate(0deg)}
    50% {transform: translate(20px, 80px) rotate(0deg)}
    100% {transform: translate(50px, -20px) rotate(5deg)}
}

body {
  background: $background-color;  
  padding: 0;
  margin: 0;
  height: 100vh;
  width: 100vw;
}

.box { width: 100px; height: 100px; background: white;
  transform-origin: 50% 0%;
  animation: rotate 2s infinite alternate ease-in-out;
}

.spaceship {
  width: 20vw;
  margin-left: 50%;
  top: 10vh;
  left: -10vw;
  position: absolute;
  animation: float 2.8s infinite alternate ease-in-out;
  transform-origin: -10% 60%;
  z-index: 20;
}

.head {
  transform-origin: 62px 52px 0;
  animation: head-nod 2s infinite alternate ease-in-out;
}

@for $i from 1 through 7 {
  .lantern_#{$i} {
     circle:nth-of-type(2){
       animation-direction: alternate;
       animation-iteration-count: infinite;
       animation-name: light;
       animation-timing-function: ease;
       animation-duration: (.2 * $i)+(s);
    }
  }
}

.leg {
  fill:#65998A;
  transform-origin: top;
  animation-duration: 2s;

  &__1 {
    @include transform-origin(30px 80px);
    animation-duration: 2s;

    &__tip {
      @include transform-origin(20px 99px 0);
      animation-duration: 2.5s
    }
  }

  &__2 {
    @include transform-origin(39px 87px);
    animation-delay: .5s;
    animation-duration: 2s;

    &__tip {
      @include transform-origin(29px 104px 0);
      animation-duration: 1.5s
    }
  }

  &__3 {
    @include transform-origin(65px 89px 0);
    animation-delay: .4s;
    animation-duration: 2.4s;

    &__tip {
      @include transform-origin(71px 102px 0);
      animation-duration: 1.5s
    }
  }

  &__4 {
    @include transform-origin(80px 80px);
    animation-duraton: 8s;

    &__tip {
      @include transform-origin(85px 99px);
      animation-duration: 1.5s
    }
  }

  &--top-center { transform-origin: 30% 0%; }
  &--top-right { transform-origin: top right; }
  &--top-left { transform-origin: top left; }
  &--moving {
    animation-direction: alternate;
    animation-iteration-count: infinite;
    animation-name: rotate;
    animation-timing-function: ease-in-out;
  }

  &--moving-tip {
    animation-direction: alternate;
    animation-iteration-count: infinite;
    animation-name: rotate;
    animation-timing-function: ease;
  }
}

.sky {
  position: fixed;
  top: 10vh;
  left: 0;
  width: 100vw;
  padding: 0;
  margin: 0;
  z-index: 10;

 .cloud {
    background-image: url("http://krystalcampioni.com/talk/clouds.svg");
    width: 100vw;
    position: absolute;
    left: 0;
    height: 100vh;
    animation-direction: normal;
    animation-iteration-count: infinite;
    animation-name: background-scroll;
    animation-timing-function: linear;
    background-repeat: repeat-x;
  }

  // styles specific to each cloud
  @for $i from 1 through 3 {
    $new-position: 10*$i;
    
    .cloud:nth-of-type(#{$i}) {   
      top: -(#{$new-position})+(vh);
      animation-duration: (10*$i)+(s);
      opacity: (.05 * ($i * 4));
    }
  }
}

.city {
    background-image: url("http://krystalcampioni.com/talk/city.svg");
  background-size: 100%;
    width: 99vw;
    position: fixed;
    left: 0;
    bottom: -30vh;
    animation-direction: normal;
    animation-iteration-count: infinite;
    animation-name: background-scroll;
    animation-timing-function: linear;
    animation-duration: 9.5s;
    height: 100vh;
    background-repeat: repeat-x;
    opacity: .5;

  &::after {
    content: " ";
    width: 100%;
    height: 32vh;
    position: fixed;
    bottom: 0;
    left: 0;
    background: #07202c;
    z-index: 1;
    opacity: 1;
  }
}

.st1{fill:#2E818E;} .st2{opacity:0.5;fill:#19474C;} .st3{fill:#FFFFFF;} .st4{fill:#1C4420;} .st5{fill:#389B47;} .st6{opacity:0.5;fill:#2E818E;} .st7{fill:#4DB858;} .st8{fill:#ADD799;} .st9{fill:#D9EBCE;}

              
            
!

JS

              
                // example created for "Alien Invasions, SVGs and CSS Animations"

// Read the full tutorial here:  https://journal.helabs.com/alien-invasions-svgs-and-css-animations-d56c4d757209
              
            
!
999px

Console