Pen Settings



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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource


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


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.


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.



<div class="buttons"id="buttonBlue">Play Blue</div>
<div class="buttons" id="buttonTwo">Play Two</div>
<div class="buttons" id="buttonFoo">Play Foo</div>

<div class="boxes" id="blue">blue</div>
<div class="boxes" id="two">two</div>
<div class="boxes" id="foo">foo</div>


                body {
  margin: 10px;

.buttons {
  //position: absolute;
  top: 10%;
  width: 100px;
  height: 50px;
  color: white;
  text-align: center;
  padding-top: 10px;
  border: 3px solid black;
  display: inline-block;

#buttonBlue {
  background: blue;
  left: 3vw;

#buttonTwo {
  background: grey;
  left: 9vw;

#buttonFoo {
  background: brown;
  left: 15vw;

.boxes {
  position: absolute;
  color: white;
  left: 80vw;
  width: 100px;
  height: 100px;

#blue {
  top: 20%;
  background: blue;
  border: 3px solid red;

#two {
  top: 40%;
  background: blue;
  border: 3px solid red;

#foo {
  top: 60%;
  background: blue;
  border: 3px solid red;


var boxes = $(".boxes");
var tweens = [];

$(".buttons").each(function(i, element) {
  // Assign a tween index to the button
  $(this).data("tween", i);
  // Create the tween this button will control
  tweens[i] =[i], 1, { left: "3vw" }).reversed(true);

$(".buttons").click(function() {

  // Get the tween index number
  var selected = $(this).data("tween");

  // Go through all the tweens and reverse them except for the
  // selected tween, which will be toggled
  for (var i = 0; i < tweens.length; i++) {    
    var reverse = i !== selected ? true : !tweens[i].reversed();