Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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

Auto Save

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 class="running_man">
  <div class="textarea">
    <span>Continuous<br>img Animation</span>
    <span>Run</span>
    <span>ning</span>
    <span>Man</span>
  </div>
  <figure class="man"></figure>
</div>


<!-- for preloading images -->
<div id="preload">
   <img src="http://www.vicchoutw.com/codepen/images/javascript/running/runman1.png"/>
   <img src="http://www.vicchoutw.com/codepen/images/javascript/running/runman2.png"/>
   <img src="http://www.vicchoutw.com/codepen/images/javascript/running/runman3.png"/>
   <img src="http://www.vicchoutw.com/codepen/images/javascript/running/runman4.png"/>
   <img src="http://www.vicchoutw.com/codepen/images/javascript/running/runman5.png"/>
   <img src="http://www.vicchoutw.com/codepen/images/javascript/running/runman6.png"/>
   <img src="http://www.vicchoutw.com/codepen/images/javascript/running/runman7.png"/>
   <img src="http://www.vicchoutw.com/codepen/images/javascript/running/runman8.png"/>
</div>
<!-- end preloading images -->
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Luckiest+Guy');

* {
  padding: 0;
  margin: 0;
}

body {
  background: #f8efe2;
  // position: relative;
}

#preload {
  display: none;
}

.running_man {
  width: 570px;
  height: 270px;
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  margin: auto;
  
  .man {
    z-index: 10;
    top: -130px;
    left: -600px;
    position: absolute;
    width: 640px;
    height: 480px;
    // transition: all 1000ms;
    background-size: cover;
    // background-image: url('http://www.vicchoutw.com/codepen/images/javascript/running/runman1.png')
  }
  
  .textarea span {
    font-size: 24px;
    display: block;
    color: #1d1f20;
    opacity: 0;
    font-family: 'Luckiest Guy', cursive;
    
    &:nth-child(1) {
      margin-left: 7px;
      transform: translateX(-100px);
      transition: all 400ms 400ms;
    }
    
    &:nth-child(2) {
      z-index: 12;
      font-size: 160px;
      color: #1d1f20;
      transform: translateX(-100px);
      transition: all 400ms 600ms;
      position: relative;
    }
    
    &:nth-child(3) {
      z-index: 9;
      position: absolute;
      display: block;
      font-size: 120px;
      margin: -135px 0 0 300px;
      transform: translateX(-100px);
      transition: all 400ms 700ms;
    }
    
    &:nth-child(4) {
      color: #ef3a55;
      margin-top: -45px;
      font-size: 130px;
      transform: translateX(-100px);
      transition: all 400ms 800ms;
    }
  }
  
  &.active {
    .textarea span {
      transform: translateX(0px);
      opacity: 0.95;
    }
  }
}


              
            
!

JS

              
                (function(){
  //main Animation
  function runmanLoad () {
    var num = 1;
    var speed = 80;
    var maxImgCount = 8;
    var $content = $('.running_man');
    var $man = $('.man');
    
  //do the man running after addclass
  $.when(
      $content.addClass('active')
  ).done(function(){
      $man.animate({left: 0}, 1200);
    
      setInterval(function(){
        num = num + 1;
        //back to the first img
        if (num > 0 && num === maxImgCount) {
          num = 1;
        }
        
        //change the img url per 0.08sec
        var newLInk = 'http://www.vicchoutw.com/codepen/images/javascript/running/runman' + num + '.png';
        $man.css({'background-image': 'url(' + newLInk + ')'});
      }, speed)
      
    })
  }
  
  //window preload images
  function addLoadEvent(runmanLoad) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') { 
        window.onload = runmanLoad;
    } else { 
        window.onload = function() {
          if (oldonload) {
              oldonload();
          }
      runmanLoad();
        }
    }
  }

addLoadEvent(runmanLoad);

})();

              
            
!
999px

Console