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 id="nav">
  <button id="play">play</button>
  <button id="pause">pause</button>
  <button id="reverse">reverse</button>
</div>
<div id="cloudContainer"></div>
              
            
!

CSS

              
                #nav {
  background-color:black;
  padding:10px;
}

button {
  padding:10px;
  cursor:pointer;
}
#cloudContainer {
  position:relative;
  width:100%;
  height:400px;
  background-color:blue;
  overflow:hidden;
}

.cloud{
 position:absolute;
 width:100px;
 height:50px; 
 border-radius:50%;
 background-color:white;
} 

              
            
!

JS

              
                var allClouds = new TimelineLite(),
    $cloudContainer = $("#cloudContainer");


function initClouds() {
  //loop through creation of 10 clouds
  for(var i = 0; i < 10; i ++){
    //dynamically create a cloud element
    var cloud = $('<div class="cloud"></div>').appendTo($cloudContainer);
    //set its initial position and opacity using GSAP
    TweenLite.set(cloud, {left:-100, top:i*40, opacity:0});
    //create a repeating timeline for this cloud
    var cloudTl = new TimelineMax({repeat:-1});
    //fade opacity to 1
    cloudTl.to(cloud, 0.5, {opacity:1})
    //move cloud across its container div with random duration. Start time = 0
    .to(cloud, 6 + (Math.random() * 8), {left:"100%", ease:Linear.easeNone}, 0)
    //0.5 seconds before timeline ends start fading opacity to 0 
    .to(cloud, 0.5, {opacity:0}, "-=0.5")
    //add this cloud's timeline to the allClouds timeline at a random start time.
    allClouds.add(cloudTl, Math.random()*5);
  }
}

//control allClouds timeline

$("#play").click(function(){
  allClouds.play();
});

$("#pause").click(function(){
  allClouds.pause();
});

$("#reverse").click(function(){
  allClouds.reverse();
});


initClouds();
              
            
!
999px

Console