cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation


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.

  <h1>Ball lighter v0.1 alpha</h1>
  <p>Now with promises!  Click Run button below.</p>
  <div id="circles">
    <div id="one"></div>
    <div id="two"></div>
    <div id="three"></div>
    <div id="four"></div>

  <div id="buttons">
    <button onClick="lightBallsInParallel()">Run</button>
    <button onClick="reset()">Reset</button>

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

html, body {
  font-family: 'Inconsolata';
  height: 100%;
body {
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: slategray;
section {
  border: 1px solid #666;
  width: 400px;
  background-color: #fff;
  text-align: center;
  box-shadow: 2px 2px 5px 0px rgba(50, 50, 50, 0.31);

#circles {
  padding: 10px 0 10px 0;

#circles > div {
  transition: all 0.7s;
  border: 1px solid #666;
  width: 50px;
  height: 50px;
  display: inline-block;
  border-radius: 100%;
  margin: 0 5px 0 5px;
  box-shadow: 0px 0px 4px 0px #999;

#buttons {
  margin: 10px 0 20px 0;
              const lightBall = (id) => {
  return new Promise((resolve, reject) => {
    const el = document.getElementById(id)
    if (!el) {
      reject(`Could not find element with id ${id}`)
    el.style.backgroundColor = "#FFEA85";
    el.style.boxShadow = "0px 0px 10px 0px #FFEA85";
    setTimeout(() => { resolve() }, 700)

const lightBallsInParallel = () => {
  ]).then(([result1, result2, result3, result4]) => {
    console.log("Done lighting all balls!")
  }).catch(err => alert(`error was ${err}`))

const reset = () => {
  ["one","two","three","four"].forEach(id => {
    document.getElementById(id).style.backgroundColor = "#fff"; 
    document.getElementById(id).style.boxShadow = "0px 0px 4px 0px #999";


Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.


Loading ..................