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

              
                <div id="scene">
  <div id="wood">
    <div class='tree t1'></div>
    <div class='tree t2'></div>
    <div class='tree t3'></div>
    <div class='tree t4'></div>
    <div class='tree t5'></div>
    <div class='tree t6'></div>
    <div class='tree t7'></div>
    <div class='tree t8'></div>
    <div class='tree t9'></div>
    <div class='tree t10'></div>
    <div class='tree t11'></div>
    <div class='tree t12'></div>
    <div class='tree t13'></div>
    <div class='tree t14'></div>
    <div class='tree t15'></div>
    <div class='tree t16'></div>
    <div class='tree t17'></div>
    <div class='tree t18'></div>
    <div class='tree t19'></div>
    <div class='tree t20'></div>
    <div id="earth"></div>
    <div id='kodama'>
      <div id='arm-left'></div>
      <div id='arm-right'></div>
      <div id='leg-left'></div>
      <div id='leg-right'></div>
      <div id='body'></div>
      <div id='head'>
        <div id="eye-left"></div>
        <div id="eye-right"></div>
        <div id="mouth"></div>
      </div>
    </div>

    <div id="emitter"></div>
  </div>
              
            
!

CSS

              
                $bg: #0d1814;
$wood: #635135;
$skin: #f2f2f2;
$earth: #072017;

*, *:before, *:after {
    box-sizing: border-box;
}

html,
body,
#scene {
  width: 680px;
  height: 400px;
  background: $bg;
  margin:0;
  overflow:hidden;
}

#emitter {
  position: absolute;
  left: 50%;
  top: 50%;
}

.particle {
  position: absolute;
  width: 50px;
  height: 50px;
  background: white;
  border-radius: 50%;
  transition: 5s ease-in;
  
}

#kodama {
  position:absolute;
  left:320px;
  bottom:130px;
  display:block;
  #body {
    content:"";
    position:absolute;
    display:block;
    border: 1px solid black;
    background-color: $skin;
    width:1.5em;
    height:2.5em;
    border-radius:45%;
    margin: .25em;
  }
  #arm-left {
     content:"";
    width:.5em;
    height:1.5em;
    background:$skin;
    position:absolute;
    border: 1px solid black;
    margin: .7em 0 0 0em;
    border-radius:45%;
    transform: rotate(15deg);
  }
  #arm-right {
    border: 1px solid black;
    content:"";
    width:.5em;
    height:1.5em;
    background:$skin;
    position:absolute;
    margin: .7em 0 0 1.5em;
    border-radius:45%;
    transform: rotate(-15deg);
  }
  #leg-left {
    border: 1px solid black;
    content:"";
    width:.5em;
    height:2em;
    background:$skin;
    position:absolute;
    margin: 1.3em 0 0 .3em;
    border-radius:45%;
    transform: rotate(0deg);
  }
  #leg-right {
    border: 1px solid black;
    content:"";
    width:.5em;
    height:2em;
    background:$skin;
    position:absolute;
    margin: 1.3em 0 0 1.1em;
    border-radius:45%;
    transform: rotate(0deg);
  }
  #head {
    content:"";
    width:2.8em;
    height:2.6em;
    background:$skin;
    position:absolute;
    border: solid 1px black;
    margin: -1.8em 0 0 -.3em;
    border-radius:47%;
    #eye-left {
      content:"";
      width:.5em;
      height:.55em;
      background:black;
      position:absolute;      
      margin: .9em 0 0 .25em;
      border-radius:50%;
    }
    #eye-right {
      content:"";
      width:.8em;
      height:.85em;
      background:black;
      position:absolute;      
      margin: .5em 0 0 1.5em;
      border-radius:50%;
    }
    #mouth {
      content:"";
      width:.3em;
      height:.3em;
      background:black;
      position:absolute;      
      margin: 1.8em 0 0 1.1em;
      border-radius:50%;
    }
  }
}
.crankHead {
    animation-timing-function:linear;
	  animation-duration: 1s;
  	animation-fill-mode: both;
  	animation-iteration-count: 1;
	  animation-name: crankHead;
}
.releaseHead {
    animation-timing-function:linear;
	  animation-duration: 2s;
  	animation-fill-mode: both;
  	animation-iteration-count: 1;
	  animation-name: releaseHead;
}
@keyframes crankHead {
  0% {transform: rotate(15deg); };
  100% {transform: rotate(65deg); };
}

@keyframes releaseHead {
  0% {transform: rotate(65deg); };
  5% {transform: rotate(65deg); };
  10% {transform: rotate(-25deg); };
  13% {transform: rotate(55deg); };
  16% {transform: rotate(-15deg); };
  19% {transform: rotate(45deg); };
  22% {transform: rotate(-5deg); };
  25% {transform: rotate(35deg); };
  28% {transform: rotate(5deg); };
  31% {transform: rotate(25deg); };
  34% {transform: rotate(15deg); };
  100%{transform: rotate(15deg); };
}

.fade-in-out {
    animation-timing-function:linear;
	  animation-duration: 6s;
  	animation-fill-mode: both;
  	animation-iteration-count: 1;
	  animation-name: fade-in-out;
}
@keyframes fade-in-out {
  0% {opacity: 0; top: 0px;};
  50% {opacity: .5; };    
  100% {opacity: 0; top: 20px;};
}

.fade-out {
    animation-timing-function:linear;
	  animation-duration: 2s;
  	animation-fill-mode: both;
  	animation-iteration-count: 1;
	  animation-name: fade-out;
}
@keyframes fade-out {
  0% {opacity: 1;};
  100% {opacity: 0; };    
}

#earth {
  width: 680px;
  height:400px;
  position:absolute;
  left:50%;
  margin-left: -340px;
  bottom:-255px;
  background-color: $earth;
  border-radius: 50%;
}
#wood {
  position: absolute;
  width:100%;
  height:100%;
  background-color: $wood;
  .tree {
    position:absolute;
    background-color:$bg;
    height: 500%; 
    border-radius: 50%;
    top: -200%;
    &.t1{
      width: 10px;
      left:5%;
    }
    &.t2{
      width: 15px;
      left:10%;
    }
    &.t3{
      width: 8px;
      left:15%;
    }
    &.t4{
      width: 12px;
      left:20%;
    }
    &.t5{
      width: 10px;
      top: -200%;
      left:25%;
    }
    &.t6{
      width: 15px;
      left:30%;
    }
    &.t7{
      width: 8px;
      left:35%;
    }
    &.t8{
      width: 12px;
      left:40%;
    }
    &.t9{
      width: 10px;
      left:45%;
    }
    &.t10{
      width: 15px;
      top: -200%;
      left:50%;
    }
    &.t11{
      width: 8px;
      left:55%;
    }
    &.t12{
      width: 12px;
      left:60%;
    }
    &.t13{
      width: 10px;
      left:65%;
    }
    &.t14{
      width: 15px;
      left:70%;
    }
    &.t15{
      width: 8px;
      left:75%;
    }
    &.t16{
      width: 12px;
      left:80%;
    }
    &.t17{
      width: 10px;
      left:85%;
    }
    &.t18{
      width: 15px;
      left:90%;
    }
    &.t19{
      width: 8px;
      left:95%;
    }
    &.t20{
      width: 12px;
      left:50%;
    }
  }
}
              
            
!

JS

              
                $('.tree').each(function (t) {
  var rot = Math.round(Math.random() * 2) - 1;
 // var rot = Math.floor(Math.randMinMax(-5,5));
  
  $(this).css({ WebkitTransform: 'rotate('+rot+'deg)'});
});

$('#kodama').hover(
  function() {
    $(this).find('#head').addClass('crankHead').removeClass('releaseHead');
  },
  function() {
    $(this).find('#head').addClass('releaseHead').removeClass('crankHead');
    $(this).animate({opacity:0}, 2000, function() {
        $(this).css('left', Math.randMinMax(150, 530)+'px').css('bottom', Math.randMinMax(60, 180)+'px');
        $(this).animate({opacity:1}, 2000);
    });
  }
);

var $emitter = $('#emitter'),
    emitEvery = 500, //emit new particle every X ms
    removeAfter = 7000; //remove particles after X ms

function create() {
  var $particle = $('<div class="particle" />'),
      x = Math.randMinMax(-350, 350),
      y = Math.randMinMax(-250, 250),
      color = 'white';
  
  var size = Math.randMinMax(5, 40);
      $particle.css('background', color);  
      $particle.css('width', size);
      $particle.css('height', size);
      $particle.css({webkitTransform: 'translateY('+y+'px) translateX('+x+'px)'});
     // $particle.animate({top: size*2+'px'}, 800);
      $particle.addClass('fade-in-out');
     
  
  $emitter.append( $particle );
  
  window.setTimeout(function() {
     
  }, 1);
  
  window.setTimeout(function() {
    $particle.remove();
  }, removeAfter);
  
  window.setTimeout(create, emitEvery); 
}

Math.randMinMax = function( t , n , a ) {
  var r = t + Math.random() * ( n - t )
  return a && (r = Math.round ( r ) ) , r 
}

create();
              
            
!
999px

Console